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 Re: setStringFormat doesn't always work as expected
Date Wed, 22 Jan 2014 09:15:06 GMT
Dear Svante,

Thanks for your response.

In the end I solved my problem by directly manipulating the DOM with the
"lower classes" as you call them.  However, I have also attached a template
and a class that demonstrate the problem I was having with the Simple API
setFormatString method.

The problem seems to be that when there are user defined styles present,
the setFormatString method creates a number-style element in the
content.xml file, and not in the
styles.xml file.  This means that when LibreOffice follows the reference to
this style, it cannot find it.  This behaviour of LibreOffice conforms with
the odf spec (16.1):

*Styles and font face declarations are referenced by their style:name
attribute. A referenced style or font face declaration should be defined in
the same file as the reference, or in styles.xml. *

I have included some comments in the java file to try and clarify the
problem.

Best,
Nick


2014/1/15 Svante Schubert <svante.schubert@gmail.com>

> Hi Nicholas,
>
> would it possible to test the problem in the latest sources?
> In addition could you provide an issue and attach a test case. Test
> Driven Development, you know..
>
> For ease of you, just take an existing one, so one of us might debug
> into it, if the solution might not become apparent at once.
> In general I feel more responsible for the lower classes than for the
> Simple API that IBM once added.
>
> Thanks in advance,
> Svante
>
>
> Am 14.01.2014 16:59, schrieb Nicholas Evans:
> > 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
View raw message