How to Stretch Jasper Table Columns based on Content

三世轮回 提交于 2019-12-25 08:18:51

问题


In jasper report (iReport 4.5) I need to make all table fit it's content width, Image below show how columns contain spaces which not needed

I tried "Stretch Type" to be "Relative to tallest object" but not work


回答1:


There are many possibilities for dynamic widths using PDF formats. All of these possibilities will likely involve developing custom software. It can be done, but it isn't trivial. Here are a few ways, though the column does not "stretch" per se -- the width of the column must be known before the report template is created.

It's possible to calculate the width of the column if you know the content and the font attributes (family, weight, size, etc.) in advance.

Dynamic Template

Since JRXML files have a straightforward format, it is possible to write a shell script, batch program, or application to generate .jrxml files. This allows complete control over page and column widths. The Java code will have to compile the .jrxml file before the corresponding .jasper file can be filled.

Dynamic Jasper

Use Dyanmic Jasper to create reports with dynamic widths.



来源:https://stackoverflow.com/questions/39817996/how-to-stretch-jasper-table-columns-based-on-content

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