开发者

Stretching a CrossTab's Cell Horizontally

开发者 https://www.devze.com 2023-02-22 01:31 出处:网络
How would I get a value cell [in a CrossTab widget] to stretch horizontally, rather than vertically? Stretch on overflow st开发者_如何学运维retches the cell vertically, rather than horizontally. Backg

How would I get a value cell [in a CrossTab widget] to stretch horizontally, rather than vertically? Stretch on overflow st开发者_如何学运维retches the cell vertically, rather than horizontally.


Background

If I recall correctly, cells in JasperReports were neither designed nor implemented to stretch horizontally. This was a conscious decision made by the lead developers.

You can make them stretch by generating the cross-tab cells according to the width of the data (that sentence alone should give you a feel for the scope of creating a generic solution to this problem). It is possible, but would involve creating your own class using the JasperReports API.

Imagine you have 100,000 rows of data and want the cell to auto-fit to the longest string. JasperReports would have to do one of two things:

  1. Generically modify the developer's SQL statement to query the longest string in each of the corresponding columns before running the final SQL statement. This effectively runs the query twice. If the query uses a volatile function call, then all sorts of problems can happen.
  2. Query all the rows and then determine the longest string. For queries under 10,000 records, this is not a problem. Scaling up to 100,000 rows imparts a large performance hit, and would eat a fair chunk of RAM.

Then you have to answer questions about white space: trim or not to trim? If the reporting software trims it, then the data coming back isn't a true representation of the information in the database. If the data isn't trimmed, then that cascades to more problems (such as unexpectedly super-long columns that look "empty"). Or you can make it one more thing that the developer needs to do.

It is not a trivial problem.

Alternatives

Try DynamicJasper.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号