TsWorksheetGrid row and col count problems [BUG?] lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- totya · 2016-09-25 20:54 Hi! For example the attached file from here: http://forum.lazarus.freepasc al.org/index.php/topic,34150.msg223047.html#msg223047 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Edit1.Text:= IntToStr(Grid.Worksheet.GetLastRowIndex(true));Edit2.Text :=IntToStr(Grid.Worksheet.GetLastColIndex(true)); Well, the row count is different, this file contains 400 lines, but GetLastRowIndex say: 399 The col count is much different, GetLastColIndex show: 256. (force calculation is ON, see the code above) Thanks! ---------------------------------------------------------------------- wp · 2016-09-25 21:18 Quote from: totya on September 25, 2016, 10:54:51 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Edit1.Text:= IntToStr(Grid.Worksheet.GetLastRowIndex(true));Well, the row count is different, this file contains 400 lines, but GetLastRowIndex say: 399 What´s wrong with it? You query the LastRowIndex from the worksheet (Grid.Worksheet), and for the worksheet indexes always begin at 0. The grid itself, however, may be confusing because of the FixedRows/Cols which can be on and off. There are functions TsWorksheet.GetGridRow/Col and GetWorkssheetRow/Col to convert indexes. Cell A1, for example, has indexes row=0 and col=0 for the worksheet, but row=1 and col=1 for the grid if row and column headers are on, but row=0 and col=0 if they are off. Confusing? Quote from: totya on September 25, 2016, 10:54:51 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Edit2.Text:=IntToStr(Grid.Worksheet.GetLastColIndex(true));The col count is much different, GetLastColIndex show: 256. (force calculation is ON, see the code above) I know about this bug but did not take the time to fix it. ---------------------------------------------------------------------- totya · 2016-09-25 21:36 Quote from: wp on September 25, 2016, 11:18:14 pmQuote from: totya on September 25, 2016, 10:54:51 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Edit1.Text:= IntToStr(Grid.Worksheet.GetLastRowIndex(true));Well, the row count is different, this file contains 400 lines, but GetLastRowIndex say: 399 What´s wrong with it? You query the LastRowIndex from the worksheet (Grid.Worksheet), and for the worksheet indexes always begin at 0. The grid itself, however, may be confusing because of the FixedRows/Cols which can be on and off. There are functions TsWorksheet.GetGridRow/Col and GetWorkssheetRow/Col to convert indexes. Cell A1, for example, has indexes row=0 and col=0 for the worksheet, but row=1 and col=1 for the grid if row and column headers are on, but row=0 and col=0 if they are off. Confusing? Okay, I understand it, and I think you are right. Quote from: wp on September 25, 2016, 11:18:14 pmQuote from: totya on September 25, 2016, 10:54:51 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Edit2.Text:=IntToStr(Grid.Worksheet.GetLastColIndex(true));The col count is much different, GetLastColIndex show: 256. (force calculation is ON, see the code above) I know about this bug but did not take the time to fix it. Thanks for the information!