OpenXML: Support part references with leading '/'

Issue #719 resolved
Chase Tingley created an issue

The attached XLSX was generated using the openpyxl Python library; it opens fine with LibreCalc. However, our filter doesn't like it:

java.lang.IllegalStateException: No worksheet entry with name xl/worksheets/sheet1.xml in [xl//xl/worksheets/sheet1.xml]
    at net.sf.okapi.filters.openxml.ExcelDocument.findWorksheetNumber(ExcelDocument.java:281)
    at net.sf.okapi.filters.openxml.ExcelDocument.getHandlerForFile(ExcelDocument.java:131)
    at net.sf.okapi.filters.openxml.OpenXMLFilter.nextInZipFile(OpenXMLFilter.java:483)
    at net.sf.okapi.filters.openxml.OpenXMLFilter.next(OpenXMLFilter.java:262)
    at net.sf.okapi.filters.openxml.OpenXMLFilter.next(OpenXMLFilter.java:277)
    at net.sf.okapi.steps.common.RawDocumentToFilterEventsStep.handleEvent(RawDocumentToFilterEventsStep.java:167)

The problem is that the xl/_rels/workbook.xml.rels file references the worksheet path using a leading /, like this:

  <Relationship Id="rId1" Target="/xl/worksheets/sheet1.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"/

Office normally writes part names out without the leading slash, like xl/worksheets/sheet1.xml, and apparently our code expects it to be that way.

(Workaround, if you hit this, is to open the doc in Office/LibreOffice and save it back out again.)

Comments (1)

  1. Log in to comment