Forum > FPSpreadsheet
fpspreadsheet - sfExcel5 getLastCol
(1/1)
garydale:
I'm using fpspreadsheet as part of program to update existing information matched against an external database. The problem I'm running into is that the user has to select an existing spreadsheet containing the information to be updated. I can't tell from the extension which specific version of Excel is to be loaded when the filename ends in .xls.
To get around this, I start with sfExcel8 and work my way backwards until TsWorkbook.ReadFromFile doesn't throw an exception.
This appears to work but my next hurdle is to get the first worksheet and identify the columns using the common "first row contains column names" format. This works for a recent sfExcel8 spreadsheet but not for the older sfExcel5 sheets I've tried (not sure how they were created but they open as sfExcel5, not 8).
When I getLastColNumber on the first worksheet, I get an "Access violation" error. The code in question is:
--- Code: --- MyWorkSheet := MyWorkBook.GetFirstWorksheet;
ShowMessage('getting last column number');
LastCol := MyWorkSheet.GetLastColNumber;
Str(LastCol, cLastCol);
ShowMessage('last column is ' + cLastCol);
--- End code ---
I get the first ShowMessage but not the second. The spreadsheets open OK in LibreOffice 3.3 - with the first (and only) worksheet labeled A, not Sheet 1.
Any ideas?
felipemdc:
Please open a bug report and attach a minimal test program and the spreadsheet.
Navigation
[0] Message Index