incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicholas Evans <nick.ev...@inology.nl>
Subject setStringFormat doesn't always work as expected
Date Tue, 14 Jan 2014 15:59:15 GMT
Dear odf users,

I am writing an application that makes use of the setFormatString function
from the ODF Simple API (the 0.7-incubating version that is available
through maven central).  My use case is the following:

1) I select a cell in the spreadsheet.
2) I set the style of this cell using setCellStyleName
3) I set a double value in the cell using setDoubleValue
4) I set a format for the cell using setFormatString

When I test run this sequence in a simple test project it works fine.
However, when I use the same sequence in a bigger spreadsheet, the cell is
not rendered as it should be.  When I open the generated spreadsheet in
LibreOffice and GoogleSpreadsheets, the cell is not formatted as I want,
although the double value is displayed.  However, when I open the
spreadsheet in Excel, the cell is formatted properly. If I save the file in
excel and reopen it in LibreOffice, the cell is formatted correctly.

I have compared the ods xml files before and after saving it in Excel and
there are quite substantial differences in the way in the which the styles
are handled.

Interestingly, the following sequence produces different results in my
small test project and my large project:

1) I select a cell in the spreadsheet.
2) I set the style of this cell using setCellStyleName
3) I set a double value in the cell using setDoubleValue
4) I set a format for the cell using setStringFormat
5) I get the cell style using getCellStyleName

In the small project, the style I get in step 5 is different from the one I
set in step 2. It seems that somewhere a new style is generated that is a
child of the Default style and this is returned in step 5.  However, in the
larger project, step 5 returns the style I set in step 2.

It seems like the API is working at least partially correctly, because
Excel can understand the generated spreadsheet.  However, it is rather
frustrating that LibreOffice can only understand the spreadsheet after it
has been through Excel.

Has anyone experienced such a problem before?  Do you have any suggestions
for how I could get the setFormatString to work?

Thanks for your help.

Kind regards,

Nick

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message