获取Jasper Reports表中第一行和最后一行的第一个字母 [英] Get first letter of first and last row in Jasper Reports table

查看:178
本文介绍了获取Jasper Reports表中第一行和最后一行的第一个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中使用JasperSoft Studio为教会生成注册表。页眉标题包含页面上的姓氏。因此,如果页面以A开头,则页面1将具有AD,并以D结尾。 < img src =https://i.stack.imgur.com/86a2b.pngalt =在此输入图像说明>

I am using JasperSoft Studio in Eclipse to generate a signup sheet for a church. The page header has the label of what last names will be on the page. So page 1 will have A-D, if the page starts with an A, and ends with a D.

这是对于这么简单的任务来说,结果非常复杂。我只想阅读last_name字段在每个页面的第一行和最后一行中的内容,取下它的第一个字母,然后将其粘贴在标题中。

This is turning out to be very complicated for such an easy task. I just want to read what the last_name field is in the first and last row of every page, take the first letter of it, and then stick it in the header.

欢迎任何想法,我很难过。

Any ideas are welcome, I am stumped.

推荐答案

要获取您使用的页面中字段的第一个和最后一个值< resetType 的强>变量,并在 textField 上设置正确的 evalutationTime (您需要使用2 textField正确地将它们正确对齐)

To get the first and last value of a field in a page you use variables with resetType and set the correct evalutationTime on the textField (You will need to use 2 textField aligning them correctly one next to the other)

此示例将说明如何获得第一个最后 每个页面 $ F {Last_Name} 的值

This example will show how to get the first and last value of the field $F{Last_Name} on every page

页面中字段的第一个值

变量上的 resetType 将为 resetType = 无

<variable name="firstValueOnPage" class="java.lang.String" resetType="None">
    <variableExpression><![CDATA[$F{Last_Name}]]></variableExpression>
</variable>

并且在 textField 中,使用变量使用 evaluatetion =Now(默认情况下不需要标记)

and in the textField, use the variable with evalution="Now" (that is default so no tag needed)

<textField>
   <reportElement x="30" y="19" width="100" height="20" uuid="e6421031-6db7-4fd9-995f-94cef2eb3621"/>
    <textFieldExpression><![CDATA[$V{firstValueOnPage}]]></textFieldExpression>
</textField>

页面中字段的最后一个值

您的变量的 resetType resetType =Page

<variable name="lastValueOnPage" class="java.lang.String" resetType="Page">
    <variableExpression><![CDATA[$F{Last_Name}]]></variableExpression>
</variable>

并在textField中使用变量 evaluationTime =Page

and in the textField use the variable evaluationTime="Page"

<textField evaluationTime="Page">
    <reportElement x="170" y="19" width="100" height="20" uuid="9100baa5-0095-4dc3-ac79-2cd87562a92d"/>
    <textFieldExpression><![CDATA[$V{lastValueOnPage}]]></textFieldExpression>
</textField>

要获得第一个和最后一个值的第一个字符,我看到你已经弄明白了,但要完成答案,textFieldExpression将是

To get only the first char of first and last value I see that you have already figured it out, but to complete the answer the textFieldExpression would be

<textFieldExpression><![CDATA[($V{firstValueOnPage}!=null&&$V{firstValueOnPage}.length()>0)?String.valueOf($V{firstValueOnPage}.charAt(0)).toUpperCase():""]]></textFieldExpression>

现在只需将两个textField放在一起(正确对齐)就可以了结果。

Now just put the two textField's next to each other (align them correctly) and you will have the desired result.

了解有关 resetType evalutationTime 的更多信息(来自 jasper report api 6.2.0

Some additional information to learn more about resetType and evalutationTime (from jasper report api 6.2.0)

resetType


- 在迭代期间,通过数据源
,每个记录都会增加变量报告 - 在报告填写过程中变量永远不会增加。

页面 - 变量随每个新页面递增。

- 变量随每个新列递增。

- 每次incrementGroup指定的组时变量都会递增属性中断

None - The variable is incremented with every record during the iteration through the data source Report - The variable never gets incremented during the report filling process.
Page - The variable is incremented with each new page.
Column - The variable is incremented with each new column.
Group - The variable is incremented every time the group specified by the incrementGroup attributes breaks

EvalutationTime


自动评估时间表示参与
表达式的每个变量应在引擎决定的时间进行评估。

Band 该元素将在带内进行评估结束。

一个常量,指定在填充每列后应计算表达式。
一个常量,指定在每次分组后应评估表达式。

Master 用于在主报告结束的时刻。

现在一个常量,指定表达式应在填充过程中的恰好时刻进行评估。

页面一个常量,指定在填充每个页面后应评估表达式。

报告一个常量,指定应在填充过程结束时评估表达式。

Auto Evaluation time indicating that each variable participating in the expression should be evaluated at a time decided by the engine.
Band The element will be evaluated at band end.
Column A constant specifying that an expression should be evaluated after each column is filled. Group A constant specifying that an expression should be evaluated after each group break.
Master Used for elements that are evaluated at the moment the master report ends.
Now A constant specifying that an expression should be evaluated at the exact moment in the filling process when it is encountered.
Page A constant specifying that an expression should be evaluated after each page is filled.
Report A constant specifying that an expression should be evaluated at the end of the filling process.

这篇关于获取Jasper Reports表中第一行和最后一行的第一个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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