Closed Max4409 closed 6 years ago
Hi. Nice catch ! I'll fix it. To make it clean, I will find a way to ensure that DataStyles
knows every TableCell.Type
.
After some digging, here's a first result. There are some underlying problems in this issue.
STRING
or VOID
do not currently need a specific data style. They are the default data style. (There's a tag 16.27.25<number:text-style>
in the specs, but I don't use it now.) They are not meant to be used with document.addChildCellStyle
.document.addChildCellStyle(TableCell.Type.STRING)
should obviously not generate a NPEcreateWriter
, because you want to flush data before the document is fully created (e.g. for a very big file). Thus, writer.document()
, if writer is a OdsFileWriter
AnonymousOdsFileWriter
(and not an AnonymousOdsFileWriter
OdsFileWriter
) should return a document to which you cannot add data styles (because they are added automatically).In your specific case, you have to remove document.addChildCellStyle(TableCell.Type.STRING)
. Depending on the size of your file (and perhaps performance issues), you may set the name of the file in DataStyles will be automatically created by odsFactory.createWriter
and forget about data styles.TableCell.setXXXValue
and other styles may be added on the fly (e.g. Table.setStyle
).
EDIT: I made a confusion between anonymous writers (datastyles are automatically created and styles are added on the fly) and named writers.
Fixed. You may not anymore add manually styles to a document returned by an anonymous writer. The styles (including data styles) will be added on the fly. See for instance Table.setStyle
, TableRow.setStyle
, TableCell.setStyle
, ... The data styles will be created quietly.
Thanks for your explanations.
Actually, i need to create a lot of files containing almost 35.000 lines each. Your FastOds is magic for me ! I used SimpleODF before, but it was too slow !!
Are you french ? Because I'm and I would like to explain to you what I have to do but my english is really poor !
I'm french (my english is also poor). Please open an issue with a [French]
tag before the title, and I'll be happy to help you if I can.
Hi,
here is my code : final OdsFactory odsFactory = OdsFactory.create(); final AnonymousOdsFileWriter writer = odsFactory.createWriter(); final OdsDocument document = writer.document(); document.addChildCellStyle(TableCell.Type.STRING); => generate NullPointerException
The problem is Type.STRING is unknowned in com.github.jferard.fastods.datastyle.DataStyles :
EnumMap<TableCell.Type, DataStyle> dataStyleByType