jferard / fastods

A very fast and lightweight (no dependency) library for creating ODS (Open Document Spreadsheet, mainly for Calc) files in Java. It's a Martin Schulz's SimpleODS fork
GNU General Public License v3.0
36 stars 6 forks source link

`setText` and covered cell #150

Closed jferard closed 5 years ago

jferard commented 5 years ago

Code:

    OdsFactory odsFactory = OdsFactory.create();

    final AnonymousOdsFileWriter writer = odsFactory.createWriter();
    final OdsDocument document = writer.document();
    Table table = document.addTable("sheet");

    TableRow row = table.getRow(0);
    TableCellWalker walker = row.getWalker();
    walker.setColumnsSpanned(2);
    walker.next();
    walker.setText(Text.content("A String"));
    writer.saveAs(new File("./generated_files", "test.ods"));

LO doesn't open the file:

Read Error.
Format error discovered in the file in sub-document content.xml at 1,2650(row,col).

Content of the content.xml file is:

...
<table:table-row table:style-name="ro1">
     <table:table-cell table:style-name="Default" table:number-columns-spanned="2"/>
     <table:covered-table-cell table:style-name="Default" office:value-type="string" office:string-value="">
          <text:p>A String</text:p>
     </table:table-cell>
</table:table-row>
...

A table:table-cell tag closes a table:covered-table-cell tag.