GetLastRowIndex on multiple sheets lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- MSC · 2014-09-24 08:47 I have an Excel xlsx-File with two sheets. Sheet 1 has about 300 rows while sheet 2 has about 50 rows. I read this file via sWorksheetGrid1.LoadFromSpreadsheetFile and show it on a pagecontrol with a separate tab for each sheet. When I select sheet 1 via "sworksheetgrid1.SelectSheetByIndex(1) " and call the function "sWorkSheetGrid1.Worksheet.GetLastRowIndex(true)" to get the last row on sheet 1, it always returns a value of 350, which obviously includes also sheet 2 on rowcount. When I select sheet 2, same function returns the correct value of 50. Is this a bug on sheet 1 rowcount or how can I get rowcount of sheet 1 only? Regards MSC ---------------------------------------------------------------------- wp · 2014-09-24 08:57 You are speaking of two sheets, but use index 1 to address the "first sheet" - did you consider that sheet indexes are 0-based? This means that when you want to select the "first" sheet you have to call "WorksheetGrid.SelectSheetByIndex(0); and for the "second" sheet you have to call "WorksheetGrid.SelectSheetByIndex(1)". ---------------------------------------------------------------------- MSC · 2014-09-24 09:01 Sorry, yes, that was a fault in this post of copy and paste only. ---------------------------------------------------------------------- MSC · 2014-09-24 09:19 Again sorry, missed the Lazarus data: fpSpreadsheet 1.1.4 from code typhoon FPC 2.6.4 Lazarus 1.2.4 32-bit on Windows 7 ---------------------------------------------------------------------- wp · 2014-09-24 11:20 I don't have the version history at hand, but my feeling is that fpspreadsheet 1.1.4 does not yet contain the new TsWorksheetGrid. I just uploaded a new version of the spready demo, and it shows that the rowcount updates correctly when pages are switched.