Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Java generated birt report, number on label
marianor
Hi, I have the following problem with a BIRT report that has to be generated with java code.
I have created a report to Excel dynamically with a servlet because the number of columns is dynamic.
For each cell of the table I create a Label, and put the value, but sometimes that value is numerical. Although the result is seen well in screen, the generated XLS in fact takes the numeric data like a string, which is a problem since I have to apply formulas over those cells . If I open .xls with a text editor, I see that the result in fact is a XML, and the cells are defined like this:
<Cell ss:Index="7" ss:StyleID="42" ss:MergeAcross="1" ss:MergeDown="0">
<Data ss:Type="String">458</Data>
</Cell>
If change the ?ss:Type? to ?Number? and I open it again with Excel, it recognizes the cell as a number. I haven?t found the way to create the report with that cell configuration from my BIRT code. I?ve tried the method setProperty several times with configurations I found on the Internet like:
label.setProperty("dataType", "decimal")
label.setProperty("Type", "Number")
?
And they all throw a PropertyNameException because BIRT does not recognize the property.
This is a summary of the code that I have done:
ElementFactory designFactory = reportDesignHandle.getElementFactory();
TableHandle table;
RowHandle row;
CellHandle cell;
LabelHandle label;
?
table = (TableHandle) designFactory.newTableItem(?table?, 5, 1, 4, 1);
row = (RowHandle) table.getHeader().get(i);
cell = (CellHandle) row.getCells().get(i);
label = designFactory.newLabel("label?);
label.setText(?4453?);
label.setProperty("textAlign", "center");
label.setProperty("fontWeight", "bold");
?
Thanks a lot, I?ll be looking forward to any idea you may have.
Find more posts tagged with
Comments
There are no comments yet