简体   繁体   English

在java中的jasper报告中动态增加列的宽度

[英]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. 如何在java中动态增加jasper报告中列的宽度,我尝试在java方面改变很多东西,比如阅读样式表和更改值。 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 jasperReport;

You need to get the band (JRBand) your column is in. Assuming it is in the detail band: 你需要得到你的专栏所在的乐队(JRBand)。假设它在细节乐队中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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