Lazarus

Programming => Packages and Libraries => FPSpreadsheet => Topic started by: volodimir_bond on November 09, 2018, 10:24:14 pm

Title: ReadFromFile() fails when reading an xlsx file created by ClosedXML library
Post by: volodimir_bond on November 09, 2018, 10:24:14 pm
Hi, please help

ReadFromFile() fails reading a file created by "https://github.com/ClosedXML/ClosedXML" library

it is failing inside of TsSpreadOOXMLReader.ReadSheetList(ANode: TDOMNode) function because ANode is nil.

When open the file in Excel and simply save it back, it becomes larger and with a bit different structure inside.
And I am able to open it with ReadFromFile().

Thanks,
Vlad
Title: Re: ReadFromFile() fails when reading an xlsx file created by ClosedXML library
Post by: wp on November 09, 2018, 10:49:31 pm
Please post the file which causes the issue (rename its extension to .zip, otherwise the forum software won't accept it).
Title: Re: ReadFromFile() fails when reading an xlsx file created by ClosedXML library
Post by: volodimir_bond on November 12, 2018, 09:17:07 pm
Hi,

Here is a short file that causes the issue - I changed the extension from xlsx to zip

Thanks,
Volodimir
Title: Re: ReadFromFile() fails when reading an xlsx file created by ClosedXML library
Post by: wp on November 12, 2018, 11:51:33 pm
Thank you for posting the file.

The problem is that OpenXML seems to write xlsx files in a different way than Excel does. The worksheet list - which causes the crash - is written by Excel (and fpspreadsheet) like this:
Code: XML  [Select][+][-]
  1. <sheets>
  2.   <sheet name="Sheet 1" sheetId="2" r:id="rId1" />
  3. </sheets>

But your file uses here a namespace "x":
Code: XML  [Select][+][-]
  1. <x:sheets>
  2.   <x:sheet name="Sheet 1" sheetId="2" r:id="rId2" />
  3. </x:sheets>

And it is not only the sheets node - almost all nodes are in namespace x, and this means changes at numerous places  -->  Fixed in r6726.
TinyPortal © 2005-2018