Recent

Author Topic: ReadFromFile() fails when reading an xlsx file created by ClosedXML library  (Read 3817 times)

volodimir_bond

  • Newbie
  • Posts: 2
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

wp

  • Hero Member
  • *****
  • Posts: 11855
Please post the file which causes the issue (rename its extension to .zip, otherwise the forum software won't accept it).

volodimir_bond

  • Newbie
  • Posts: 2
Hi,

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

Thanks,
Volodimir

wp

  • Hero Member
  • *****
  • Posts: 11855
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.
« Last Edit: November 13, 2018, 05:47:49 pm by wp »

 

TinyPortal © 2005-2018