Recent

Author Topic: fpspreadsheet - sfExcel5 getLastCol  (Read 5446 times)

garydale

  • New Member
  • *
  • Posts: 17
fpspreadsheet - sfExcel5 getLastCol
« on: August 01, 2011, 11:14:24 am »
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: [Select]
MyWorkSheet := MyWorkBook.GetFirstWorksheet;
ShowMessage('getting last column number');
LastCol := MyWorkSheet.GetLastColNumber;
Str(LastCol, cLastCol);
ShowMessage('last column is ' + cLastCol);

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

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: fpspreadsheet - sfExcel5 getLastCol
« Reply #1 on: August 01, 2011, 04:06:48 pm »
Please open a bug report and attach a minimal test program and the spreadsheet.

 

TinyPortal © 2005-2018