Le 02/04/2013 23:26, PhilipN a écrit :
Hi,

Hi,

I found that using jOpenDocument (even 1.3rc1) it is not possible to write
boolean values to a spreadsheet.
I suspect part of the issue that jOpendocument doesn't write the proper
office:value-type tag in the table cells.

AFAICS office-value-type fields aren't written for other cell contents
types either:  text,  data,  time, ......
I only see "office:value-type:float" tags in jOpenDocument-generated table
cells.

Until 1.2, only string, float and date were supported. Since 1.3, setValue() can infer the type from the value, or one can pass an ODValueType.


public static void main(String[] args) throws IOException {
    final Sheet sheet = SpreadSheet.create(1, 3, 3).getFirstSheet();
    sheet.getCellAt("A1").setValue("On site support");
    sheet.getCellAt("A2").setValue(new Date());
sheet.getCellAt("A3").setValue(TimeUtils.getTypeFactory().newDuration("P2DT26H30M11S"), ODValueType.TIME, false, false);
    sheet.getCellAt("B1").setValue(3);
    sheet.getCellAt("B2").setValue(0.33333, ODValueType.PERCENTAGE, false, 
false);
    sheet.getCellAt("B3").setValue(true);

    OOUtils.open(sheet.getSpreadSheet().saveAs(new File("out")));
}

If you unzip out.ods, you will see the proper value-type attributes are 
generated.


It also strikes me that all table-cells in a spreadsheet created with
jopendocument contain the tag:
      xmlns:text="*urn:oasis:names:tc:opendocument:xmlns:text:1.0*"
Isn't this an enormous waste of JVM memory, or even disk memory, as this
info is repeatedly present in memory for each cell once the spreadsheet
file is unpacked?
Or is this tag only generated when jopendocument objects are exported from
the Java world?

In memory the same instance of Namespace is used by JDOM. If JDOM exports it for each cell it means no common XML element ancestor defines it. It might have happened in 1.2 (though the workaround is simple), but in 1.3 this can no longer happen since the root element defines it.


Thanks,

Philip


Cheers,
Sylvain


--

--- You received this message because you are subscribed to the Google Groups "jOpenDocument" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jopendocument+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to