Quantcast
Channel: BIRT Exchange Forum Feed
Viewing all articles
Browse latest Browse all 542

CrossTab cell formatting?

$
0
0
Hi,

I have report with several graphs and one crosstab. The layout of the crosstab is as follows

ColumnName[colIndex]

DataFrom | DataType[rowIndex] || Data

It should look something like

Monday Tuesday ......

Paris Furniture 1200 2000
Candies 120 220

ROI 5.5% 7.0%


London Furniture 2200 2700
Candies 220 320

ROI 6.5% 8.0%

etc

The data is produced by a database query and all computation is done (in Java) before pushing the data to the
report.

A line of data to the report looks like:

{dataFrom:sales, dataType:candies, columnName:Monday, columnIndex:1, data:1200,.....}

Everything works okay, for the exception of the rows (and a specific columns) containing percentages. All data, including percentage is pushed in the double datatype from Java, i.e. 0.055 for 5.5%. The report design data type is decimal.

The requirement of the rows and columns containing percentages is that its shows the %-sign and if value is positive the color of the cell/number should be green, if negative then red.

I have managed to get the colors on the correct row and column cells containing the percentages. However I am unable to get the % sign into those same cells.

In the crosstab script I have
function onCreateCell( cellInst, reportContext )
{
if( cellInst.getDataValue("columnName")=="ComparedToPreviousMonth" 	|| 
cellInst.getDataValue("dataType")=="ROI")
{	
	

// cellInst.getStyle().setNumberFormat("##.##%");
			
if(cellInst.getDataValue("data_TypeGroup/dataType_columns/columnName") < 0) 
cellInst.getStyle().setColor("RGB(253,120,120)");
	
if(cellInst.getDataValue("data_TypeGroup/dataType_columns/columnName") > 0) 
cellInst.getStyle().setColor("RGB(0,139,8)");


}

}


As I said the coloring works correctly for the given rows and columns. But if I remove the comment on the line with setNumberFormat, then every cell in the whole crosstab gets formatted with % and extra zeros.

It appears that setNumberFormat somehow affects every cell while the coloring works as expected, for the specified row and column cells.

How should I solve this problem?

Viewing all articles
Browse latest Browse all 542