JasperReports文本字段拉伸 - 拉伸高度是否有限? [英] JasperReports text field stretching - can stretch height be limited?

查看:665
本文介绍了JasperReports文本字段拉伸 - 拉伸高度是否有限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JasperReports子报表中遇到了以下问题,过去几天我一直试图解决这个问题,但没有成功。下面是我正在尝试做的图片。

I've got the following problem with a JasperReports subreport that I've been trying to solve for the past couple of days with no success. Below is an image of what I'm trying to do.

我的报告中有一个子报告相对简单。它有一个带有单个文本字段(图像中标记为棕色)的标题带,用于子报告标题和一个带有两个项目的细节带:一个子报告(图像中标记为蓝色)打印我的行项目和一个文本字段(标记为红色)图像)打印与打印在其左侧的行项目相关的注释。订单项子报表可以打印可变数量的订单项(由bean集合支持的数据源)。我的客户要求是注释字段拉伸并显示输入的文本,但受行项目部分的高度限制(由图像上的箭头表示)。我不知何故需要阻止评论超出行项目并使它们具有相同的高度(图像中应该没有绿色框)。

I've got a subreport in one of my reports that is relatively simple. Its got a title band with a single text field (marked brown in the image) for the subreport title and a detail band with two items: a subreport (marked blue in the image) printing my line items and a text field (marked red in the image) printing the comments associated with the line items printed to the left of it. The line item subreport can print a variable number of line items (datasource backed by a bean collection). My customers requirement is that the comments field stretches and shows the text entered, but be limited by the height of the line item section (represented by the arrows on the image). I somehow need to prevent the comments from stretching beyond the line items and make them of equal height (there should be no green box in the image).

有没有人有任何提示如何在JasperReports中实现(并且可以完全实现)?

Does anyone have any tips how this could be (and can it at all be) achieved in JasperReports?

ps
我们目前正在使用JR 3.6版编译我们的报告

p.s. We are currently compiling our reports with JR version 3.6

推荐答案

将子报表和文本字段放入框架中。对于文本字段,将Stretch with overflow设置为 false Stretch type设置为相对于最高对象

Put both the subreport and the text field into a frame. For the text field, set "Stretch with overflow" to false and "Stretch type" to "Relative to tallest object"

文本字段将相对于其容器中的最高对象进行拉伸。它的容器现在是框架,因此最高的对象只能是子报告。确定元素在定义时的高度相同,否则它们将以不同的速率增长。

The text field will stretch relative to the tallest object in it's container. It's container is now the frame, so the "tallest object" can only be the subreport. Make sure the elements are the same height when you define them, otherwise they will grow at different rates.

JRXML样本:

<band height="50">
    <frame>
        <reportElement x="0" y="0" width="555" height="50"/>
        <subreport>
            <reportElement x="0" y="0" width="378" height="50"/>
            ...
        </subreport>
        <textField isStretchWithOverflow="false">
            <reportElement stretchType="RelativeToTallestObject" x="378" y="0" width="177" height="50"/>
            ...
        </textField>
    </frame> 
</band>

这篇关于JasperReports文本字段拉伸 - 拉伸高度是否有限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆