Jasper 报告语法 报告元素和框架

发布于 2024-12-01 23:05:49 字数 884 浏览 1 评论 0原文

我试图了解 jasper 报告是如何工作的,但我发现语法有点难以掌握。

reportelement-key 到底指的是什么?框架也是一个纯粹的视觉组件吗?

<frame>
    <reportElement key="frame-6" mode="Opaque" x="0" y="36" width="534" height="36" backcolor="#CCCCCC"/>
    <box>
        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <bottomPen lineWidth="0.0" lineColor="#000000"/>
        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    </box>
</frame>

另外,下面的 F 和 v 表示什么,更重要的是它们在哪里定义?

<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{amountTotal}]]></textFieldExpression>
<variableExpression><![CDATA[new BigDecimal($F{amount percentage})</variableExpression>

I'm trying to understand how jasper reports work but i find the syntax a little difficult to get to grips with.

what exactly does reportelement- key refer to? also is frame a purely visual component?

<frame>
    <reportElement key="frame-6" mode="Opaque" x="0" y="36" width="534" height="36" backcolor="#CCCCCC"/>
    <box>
        <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
        <bottomPen lineWidth="0.0" lineColor="#000000"/>
        <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
    </box>
</frame>

Also in the following what do the F and v indicate, and more importantly where are they defined?

<textFieldExpression class="java.math.BigDecimal"><![CDATA[$V{amountTotal}]]></textFieldExpression>
<variableExpression><![CDATA[new BigDecimal($F{amount percentage})</variableExpression>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独陪着我 2024-12-08 23:05:49

关于框架:

引自IReport Ultimate Guide:

框架是一个可以包含其他元素的元素,并且可以选择
在它们周围画一个边框。

..
由于框架是其他框架的容器
元素,在文档大纲视图中,框架表示为
包含其他元素的节点。

..
一个框架可以包含其他框架,并且
如此递归。要将元素添加到框架中,只需拖动新元素即可
框架内调色板中的元素。或者你可以使用
大纲视图并将元素从带区拖到框架中等等
在。元素的位置始终相对于容器
位置。如果容器是一个带区,则元素位置将为
相对于带的顶部和左边距。如果容器
(或元素父级)是一个框架,元素坐标将是
相对于框架的左上角。由于拖动了一个元素
从一个容器到另一个容器不会改变其顶部/左侧属性,
当将一个元素从一个容器移动到另一个容器时,它的位置是
根据新的集装箱位置重新计算。
使用框架在一组周围绘制边框的优点
相对于使用简单的矩形元素,元素是:

* 当你移动一个框架时,框架中包含的所有元素都会移动
一致行动。

* 使用矩形重叠某些元素时,
矩形内的元素不会被视为重叠
(相对于框架),因此在以 HTML 格式(不支持重叠元素)导出时不会出现问题。

* 最后,框架会根据其大小自动拉伸
内容,及其元素的元素位置类型属性将
参考框架本身,而不是表带,使设计有点
更容易管理。
在 HTML 中(不支持重叠元素)。

关于reportElement

引用自JasperReports Ultimate Guide:

报告元素属性

当您将报表元素添加到报表部分之一时,您必须
指定该元素在该特定元素中的相对位置
部分及其大小,以及其他一般报告元素
颜色、透明度、拉伸行为等属性。

所有类型的报表元素共有的属性是
分组在标签中,该标签出现在声明中
所有报告元素。

..
元素键

与变量和参数不同,报表元素不是
需要有一个名字,因为通常你不需要获得
报告模板中的任何单个元素。然而,在一些
在这种情况下,能够找到一个元素来改变它的其中一个元素是很有用的
使用报告模板之前的属性。情况可能是这样的
报告中某些元素的颜色的应用程序
模板需要根据用户输入进行更改。找到报告
需要改变颜色的元素,调用者程序
可以使用频段级别可用的 getElementByKey(String) 方法。
键值必须与报表元素关联,并且必须是
在整个范围内是唯一的,以便查找工作。关键
属性用作提供的示例
/demo/samples/alterdesign 示例。

关于字段 ($F) 和变量 ($V):

  • $F{fieldName} 是对名称为 fieldName 的字段的引用。这些字段包含来自数据源的数据。
  • $V{variableName} 是对名称为 variableName 的报表变量的引用。变量具有表达式,可用于不同的计算。

About the frame:

The quotes from IReport Ultimate Guide:

A frame is an element that can contain other elements and optionally
draw a border around them.

..
Since a frame is a container of other
elements, in the document outline view the frame is represented as a
node containing other elements.

..
A frame can contain other frames, and
so on recursively. To add an element to a frame, just drag the new
element from the palette inside the frame. Alternatively you can use
the outline view and drag elements from a band into the frame and so
on. The position of an element is always relative to the container
position. If the container is a band, the element position will be
relative to the top of the band and the left margin. If the container
(or element parent) is a frame, the element coordinates will be
relative to the top left corner of the frame. Since an element dragged
from a container to another does not change its top/left properties,
when moving an element from a container to another its position is
recalculated based on the new container location.
The advantages of using a frame to draw a border around a set of
elements, with respect to using a simple rectangle element, are:

* When you move a frame, all the elements contained in the frame will
move in concert.

* While using a rectangle to overlap some elements,
the elements inside the rectangle will not treated as overlapped
(respect to the frame), so you will not have problems when exporting in HTML (which does not support overlapped elements).

* Finally, the frame will automatically stretch accordingly to its
content, and the element position type property of its elements will
refer to the frame itself, not to the band, making the design a bit
easier to manage.
in HTML (which does not support overlapped elements).

About the reportElement

The quotes from JasperReports Ultimate Guide:

REPORT ELEMENT PROPERTIES

When you add a report element to one of your report sections, you must
specify the relative position of this element in that particular
section and its size, along with other general report element
properties like color, transparency, stretch behavior, and so forth.

The properties that are common to all types of report elements are
grouped in the tag, which appears in the declaration
of all report elements.

..
ELEMENT KEY

Unlike variables and parameters, report elements are not
required to have a name, because normally you do not need to obtain
any individual element inside a report template. However, in some
cases it is useful to be able to locate an element to alter one of its
properties before using the report template. This could be the case in
an application for which the color of some elements in the report
template needs to change based on user input. To locate the report
elements that need to have their colors altered, the caller program
could use the getElementByKey(String) method available at band level.
A key value must be associated with the report element and it must be
unique within the overall band for the lookup to work. The key
attribute is used as an example in the provided
/demo/samples/alterdesign sample.

About the fields ($F) and variables ($V):

  • $F{fieldName} is a reference to the field with name fieldName. The fields contains data from a data source.
  • $V{variableName} is a reference to the report's variable with name variableName. The variable have expression and can be used for different calculations.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文