A PHP spreadsheet reader (Excel XLS and XLSX, OpenOffice ODS, and variously separated text files) with a singular goal of getting the data out, efficiently
This code is wrong for obvious reason. You cannot make an assumption that r:id attribute always contains correct sheet ID at the end, in fact r:id can contain any random string.
When i save XLSX document in LibreOffice Calc, this reader cannot read the document.
Example document where workbook.xml file contains following data: <sheets> <sheet name="MyData" sheetId="1" state="visible" r:id="rId2"/> </sheets>
As you see here sheetId = "1", and relation id is "rId2"
SpreadsheetReader_XLSX.php contains method Sheets() with a code:
This code is wrong for obvious reason. You cannot make an assumption that r:id attribute always contains correct sheet ID at the end, in fact r:id can contain any random string.
The best option to solve this issue would be to rewrite Sheets() method so that it will look up correct sheet in a file called workbook.xml.rels. In my example workbook.xml.rels file looke like this: <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/> <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/> <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/> </Relationships>