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

北城余情 提交于 2021-02-07 20:43:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!