简体   繁体   中英

increase the width of a column dynamically in jasper reports in java

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.

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);

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM