[Lazarus] Fpsreadsheet bug?

Malcolm Buckingham mjb at admagres.com
Mon Oct 30 11:46:35 CET 2017


I've run into a problem using fpsreadseet. I'm getting the following
exception:-

Project ezcel raised exception class 'EListError' with message:
List index (0) out of bounds.

I'm using Lazarus v1.2.6 and fpspreadsheet 1.8.4. The problem occurs under
Windows 7 and 10.

The location of the error is Line 1246 in xlscommon.pas, function
TsSpreadBIFFReader.FixFontIndex  :-

  fnt := TsFont(FFontList[AFontIndex]); 

My "ezcel" program reads spreadsheets from a number of different sources and
allows the user to automatically extract data for adding into a database.
Most spreadsheets work OK but the ones that cause the problem are BIFF8
files that have no FONT records in the workbook globals. The comments at the
start of xlsbiff8.pas state that there should be FONT records, and the
OpenOffice.org's documentation says the same thing.

However both Excel and LibreOffice read the files OK, and when re-saved
ezcel opens them correctly because the FONT records have been added. 

After more debugging I discoved that when loading a .xls file procedure
TsWorkbook.InitFonts; is called ( twice ) presumably to handle cases where
FONT records are missing. The procedure sets 4 default fonts.


At line 8099 in fpspreadsheet.pas I evaluated FFontList. The code and result
were:-

AReader.ReadFromFile(AFileName, AParams); 
<TFPLIST> = {
  <TOBJECT> = {
    _vptr$ = {
      0x63bf34, 
      0x314a3f0}}, 
  FLIST = $314a3f0, 
  FCOUNT = 4, 
  FCAPACITY = 4}

I then single stepped to the next line of code, which was line 466 in
fpsReaderWriter. This was the start of procedure
TsCustomSpreadReader.ReadFromFile

<TFPLIST> = {
  <TOBJECT> = {
    _vptr$ = {
      0x63bf34, 
      0x0}}, 
  FLIST = $0, 
  FCOUNT = 0, 
  FCAPACITY = 0}

I don't really understand how objects are stored but it seems they consist
of two pointers; one for the code and one for the data. In this case the
data pointer is being trashed which leads to an empty fonts list.

So, is this a bug or a case of there simpy being a problem with the excel
file? I should point out that the software can read BIFF2 files even with no
font information. With the BIFF8 files there are INT_EXCEL_ID_XF records in
Workbook Globals and these record need to access he fonts.

I hope someone can help.

Malcolm








More information about the Lazarus mailing list