Recent

Author Topic: FPspreadsheet: cant open XLS file  (Read 1384 times)

vincococka

  • Full Member
  • ***
  • Posts: 101
FPspreadsheet: cant open XLS file
« on: April 17, 2019, 12:04:04 am »
Dear community,

if I try to open via TsWorkbookSource xls file (format: excel 1997-2003 - EXCEL8), it throws exception mentioning List index (-1) out of range.
After debugging it hangs on following function in file common \ fpsreaderwriter.pas -> TsSpreadFormatRegistry.GetFormatArray

  // Rearrange the formats such the one noted in APriorityFormats are at the top
  if Length(APriorityFormats) > 0 then
    for i := High(APriorityFormats) downto Low(APriorityFormats) do
    begin
      idx := IndexOf(APriorityFormats);
      data := TsSpreadFormatData(FList[idx]);
      FList.Delete(idx);
      FList.Insert(0, data);
    end;

Platform:
  Windows 7, FPC 3.0 Stable, Lazarus 2.0.2, fpspreadsheet 1.11 viac FpcUpDeluxe

Any ideads why it happens? Ive attached problematic document - just in case.
---
  Guide me God and I`ll find you

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: FPspreadsheet: cant open XLS file
« Reply #1 on: April 17, 2019, 11:20:29 am »
For each file format FPSpreadsheet has a separate unit with the reader/writer code. In order to avoid linking unnecessary code only those readers/writer units can be added to the "uses" clause which are needed by the application, or add "fpsallformats" to get support for all file formats implemented.

xls support for various versions is contained in units "xlsbiff8", "xlsbiff5" and "xlsbiff2". "xlsbiff8" corresponds to the latest xls version in Excel97 before Excel2007 with the xlsx format was released (unit "xlsxooxml"). "xlsbiff5" corresponds to Excel95 and "xlsbiff2" to Excel 2.1.
« Last Edit: April 17, 2019, 05:00:05 pm by wp »

vincococka

  • Full Member
  • ***
  • Posts: 101
Re: FPspreadsheet: cant open XLS file
« Reply #2 on: April 17, 2019, 12:22:51 pm »
Dear wp,

thanks for explanation, after appending unit "fpsallformats" to uses section everything works as expected.

KUDOZ !
---
  Guide me God and I`ll find you

 

TinyPortal © 2005-2018