I have a quite basic template in .jrxml which contains crosstab element with header and one cell.
I am using crosstab, because i have dynamic number of columns. I am giving datasource as parameter from bean so i know a number of columns right before report generation. I want columns of "dynamic" width.
I am trying to read existing jrxml and then repair column width based on number of columns right before report generation.
Until now i found out how to load file and and i am getting right band(i know it's always second) and right element(dynamicCrosstab). I can't find out how to set column width.
My current code:
JasperDesign template = JRXmlLoader.load("C:\\repos\\templateFile.jrxml");
JRBand[] bands = template.getAllBands();
//getting crosstab
JRElement element = bands[1].getElementByKey("dynamicCrosstab");
if (element instanceof JRCrosstab) {
//missing code to get cells and set width
}
//compiling template before using it to generate report
JasperCompileManager.compileReportToFile(template, "C:\\repos\\templateFile.jasper");
Tnx for any help in advance.