问题
How do i increase the width of a column in jasper reports dynamically in java, i have tried changing many things in java side like reading the style sheet and changing the values. But in this case i don't know how to initialize the method which will read the width and change it.
回答1:
Lets say your report variable is called jasperReport
JasperReport jasperReport;
You need to get the band (JRBand) your column is in. Assuming it is in the detail band:
JRBand band = jasperReport.getDetail();
And then find your column and change it's width:
JRElement column = band.getElementByKey("key_for_column");
column.setWidth(123);
回答2:
This way column will use full page width available
myReport.addColumn(myColumn);
myReport.setTitle("column should use full width available");
myReport.setUseFullPageWidth(true); //make colums to fill the page width
来源:https://stackoverflow.com/questions/1215798/increase-the-width-of-a-column-dynamically-in-jasper-reports-in-java