1
I’m working with DynamicJasper
to generate a report with a Crosstab with dynamic columns, but I’m having a problem, the table you’re generating is exceeding the page width limit and some columns are being cut from the table, but the columns are disproportionately large, what I want is that no matter how many columns or how large the texts of the columns, the Jasper
automatically reduce the width of the columns until they are all visible, but I haven’t found anything so far that can help me with this, both by DynamicJasper
how much for Jasper
pure. Someone can help me?
Code:
/*
Create an empty report (no columns)!
*/
final FastReportBuilder drb = new FastReportBuilder();
drb.setPageSizeAndOrientation(new Page(582, 854, false))
.setPrintColumnNames(false)
.setUseFullPageWidth(true)
.setWhenNoData("No data for this report", null)
.setDefaultStyles(this.titleStyle, null, null, null)
.setMargins(0, 0, 0, 0);
final DJCrosstab djcross = new CrosstabBuilder()
.setHeight(582)
.setWidth(854)
.setHeaderStyle(this.mainHeaderStyle)
.setDatasource("sr", DJConstants.DATA_SOURCE_ORIGIN_PARAMETER, DJConstants.DATA_SOURCE_TYPE_COLLECTION)
.setUseFullWidth(false)
.setColorScheme(DJConstants.COLOR_SCHEMA_LIGHT_GREEN)
.setAutomaticTitle(false)
.setCellBorder(Border.THIN())
.addRow("Product Line", "productLine", String.class.getName(), false) // Y
.addColumn("Branch", "branch", String.class.getName(), false) // X
.addColumn("Item", "item", String.class.getName(), false) // X
.addMeasure("amount", Float.class.getName(), DJCalculation.SUM, "Amount",
this.measureStyle)
.setRowStyles(this.colAndRowHeaderStyle, this.totalStyle, this.totalHeaderStyle)
.setColumnStyles(this.colAndRowHeaderStyle, this.totalStyle, this.totalHeaderStyle)
.setColumnHeaderHeight(30)
.setRowHeaderWidth(50)
.setIgnoreWidth(true)
.setBottomSpace(0)
.setTopSpace(0)
.build();
drb.addHeaderCrosstab(djcross); //add the crosstab in the header band of the report
final DynamicReport dynamicReport = drb.build();
//put a collection in the parameters map to be used by the crosstab
this.params.put("sr",
SortUtils.sortCollection(TestRepositoryProducts.getDummyCollection(), djcross));
final JasperDesign jasperDesign = generateJasperDesign(dynamicReport);
final JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
final JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, this.params, getDataSource());
JasperViewer.viewReport(jasperPrint); //finally display the report report
It is currently generating a report like this (image below), as you can see some columns are missing in this report, these columns were cut because they exceeded the page width limit.
I mean that if it is necessary to stop using Dynamicjasper for that to be possible, I stop.