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
35 stars 6 forks source link

DataStyle problems #247

Closed dimad71 closed 1 year ago

dimad71 commented 1 year ago

Hi!

1. If:

var dsf = new FloatStyleBuilder("float-datastyle", locale).decimalPlaces(0).groupThousands(true).build();
var tableHeadStyle = TableCellStyle.builder("tableHeadStyle")
            .fontSize(SimpleLength.pt(14))
            .fontWeightBold()
            .hidden()
            .dataStyle(dsf)
            .build();

cell.setStyle(tableHeadStyle); 

Then in content.xml:

<style:style style:name="tableHeadStyle" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="float-datastyle">
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" fo:font-size="14pt" style:font-size-asian="14pt" style:font-size-complex="14pt"/>
</style:style>

Has ref style:data-style-name="float-datastyle", but no <number:number-style style:name="float-datastyle" in content.xml

But if call cell.setDataStyle(dsf), then <number:number-style style:name="float-datastyle" is appears in content.xml

2. If

cell.setStyle(tableHeadStyle);
cell.setDataStyle(dsf);

Then in content.xml: <style:style style:name="tableHeadStyle-_-float-datastyle" style:family="table-cell" style:parent-style-name="tableHead2Style" style:data-style-name="float-datastyle"/>

ButtableHead2Style is automatic-style (.hidden()) and ignored by OpenOffice in style:parent-style-name attribute: "The style:parent-style-name attribute specifies the name of a parent style. The parent style cannot be an automatic style and shall exist." http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1417978_253892949

  1. I workaround it by set DataStyle to TableCellStyle and cell.setDataStyle(dsf) only in one not used empty cell.

jferard commented 1 year ago

Hello ! Thanks for reporting this. I'll have a look.