miachm / SODS

A simple Java library for handle ODS (Open Document Spreadsheet, compatible with Excel and Libreoffice)
The Unlicense
74 stars 30 forks source link

ods file generate by pyexcel-ods failed to read #43

Closed JayHsuEgg closed 2 years ago

JayHsuEgg commented 2 years ago

Hi Miachm,

Lately I'm trying to use pyexel-ods to generate ods file, and use java SODS tool to read it.

However, I'm facing problem with below error message : // ------------------------------------------------------- // Exception in thread "main" java.lang.IndexOutOfBoundsException: Range goes out of bounds: (end_of_range: 1, maxcolumns in sheet: 0 at com.github.miachm.sods.Range.(Range.java:31) at com.github.miachm.sods.Sheet.getRange(Sheet.java:279) at com.github.miachm.sods.Sheet.getRange(Sheet.java:250) at com.github.miachm.sods.OdsReader.processCells(OdsReader.java:437) at com.github.miachm.sods.OdsReader.processTable(OdsReader.java:330) at com.github.miachm.sods.OdsReader.processSpreadsheet(OdsReader.java:262) at com.github.miachm.sods.OdsReader.iterateFilesEntries(OdsReader.java:255) at com.github.miachm.sods.OdsReader.processContent(OdsReader.java:80) at com.github.miachm.sods.OdsReader.load(OdsReader.java:46) at com.github.miachm.sods.OdsReader.load(OdsReader.java:38) at com.github.miachm.sods.SpreadSheet.(SpreadSheet.java:52) at com.github.miachm.sods.SpreadSheet.(SpreadSheet.java:39) at BasicUsage.main(BasicUsage.java:17) // ------------------------------------------------------- //

// ----------------------- pyexcel-ods script generate ods file ------------------------- // from collections import OrderedDict from pyexcel_ods import save_data

    data = OrderedDict() # from collections import OrderedDict
    data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
    data.update({"Sheet 2": [["row 1", "row 2", "row 3"]]})
    save_data("Jay.ods", data)

// ---------------------------------------------------------------------------------------- //

Attachment will be the ods file caused above issue

Jay.ods

github-actions[bot] commented 2 years ago

Thanks for your report! Please ensure you have provided enough info in order to recreate the issue, including the problematic ODS File.' first issue

miachm commented 2 years ago

The generated ODS file is not declaring the table:table-column tag in its XML. Which it's odd but seems an acceptable behaviour.

It should be solved with a simple if which "inserts" the unexpected columns.

JayHsuEgg commented 2 years ago

Hi Miachm,

It worked! I really appreciated your help! Thank you~

Sincerely Jay