Jasper reports 为每个报表重复行
我已经创建了一个表报告 我已将Jasper reports 为每个报表重复行,jasper-reports,Jasper Reports,我已经创建了一个表报告 我已将编号,机构名称,第一年,第二年,第三年,第四年,第五年,以及第一行和第二行的总数填入。我已将第一年,第二年,第三年,第四年,第五年的所有金额和机构总数都归入详细范围。之后,我把折线图的布局。最后,我使用$V{REPORT\u COUNT}%5==0条件设置
编号
,机构名称
,第一年
,第二年
,第三年
,第四年
,第五年
,以及第一行和第二行的总数填入。我已将第一年
,第二年
,第三年
,第四年
,第五年
的所有金额和机构总数都归入详细
范围。之后,我把折线图的布局。最后,我使用$V{REPORT\u COUNT}%5==0
条件设置
。但问题是这两行的数据都是重复的。如何解决这个问题?我想查看一个报告每页5行。结果仍然是一样的
在此附上我的代码:
更新:
如果我理解正确,您希望有5个细节行,后跟图形,然后是换行符?之所以没有发生这种情况,是因为在每个细节行之后都会打印线条图。所以它从来没有打到第五排。您需要将折线图移动到agnesi组页脚1
部分
更新:如果您只想在第一页上显示列标题,则需要在其中添加一个printWheenexpression,该printWheenexpression具有$V{page\u NUMBER}==1
第二次更新:您的报告有一些问题
- 你在页脚上放了一个分页符。这不应该
那里在页脚上加一个分页符是不可取的
一点也不
- 二是有多个细节部分。我认为这是行不通的
以你期望的方式工作。“详细信息2”部分中的项目
很可能位于
机构组页脚1
中,且无页面
中断
- 三、您的列标题似乎不正确。您正在引用
那里的田地。字段是数据源中
在组和详细信息部分迭代。最好的猜测是
应移至
机构组标题1
,而不是
列标题
- 最后,您应该在案例中放置分页符的唯一位置是
Detail 1
部分带有表达式时的打印
($V{REPORT\u COUNT}%5)==0
我发现有一件事可以帮助我保持清晰,那就是删除我没有使用的部分。一旦你做了上面我告诉过你的事情,你可以删除标题、页眉、栏头、页脚和摘要部分 你能发布你的报告设计的截图(在iReport中)和jrxml文件吗?还有Designer
视图的截图呢?你期望得到什么结果?我期望得到的结果是我希望每页5行数据,加上折线图。谢谢你的建议。我试过了,成功了。但现在的问题是,当数据小于5时,它无法读取最后一页的数据。我认为问题是“$V{REPORT\u COUNT}%5==0”。这里我附上了照片。在图片中,我将条件“$V{REPORT\u COUNT}%5==0”放在“Detail2”和“Group footer”中的“打印时表达式”中,您可以显示并告诉我或逐步告诉我如何正确排列报告。我现在的问题是当报告少于5行时,它不能显示总图和折线图。我尝试了很多次,但仍然无法工作。:(不,我不能。很抱歉,你甚至还没有发布你的jrxml文件的内容,所以所有人都必须查看链接到各地的屏幕截图。对不起,伙计。花点时间,整理和组织你上面的问题,并将你的jrxml文本(不是屏幕截图)放在上面在这个问题上。也许有人可以帮你自己。在你表现出更多的努力之前,你可能是靠自己。我的观点是,当最后一页的数据少于5行时,你有什么建议如何显示数据。如果你回过头看图片,你会看到最后一页的数据不会出现。数据只能查看5行,除此之外,我还可以查看其他行t将不显示。我已尝试发送我的jrxml文件,但它无法发送。您能告诉我如何放置代码吗。我尝试了很多次,但仍然无法在您的问题下方的右上角找到。您将有一个链接,以浅灰色标记为“编辑”。单击该链接后,您将得到一个框,其中包含问题,您可以更改您编写的内容,添加文本,删除文本、添加图像等。如果使用iReport,请在此处打开jrxml文件,然后转到“xml”选项卡。将所有文本复制到问题中。突出显示刚刚粘贴的xml,然后单击标记为{}的按钮将其格式化为代码。这是它的基础,它不必看起来完美,只需要文本。其他人可以在需要时清理它。
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="charttest" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="99"/>
<parameter name="P_YEAR" class="java.lang.String">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Documents and Settings\\NT\\Desktop\\CHART\\"]]></defaultValueExpression>
</parameter>
<field name="PARENT_NAME" class="java.lang.String"/>
<field name="PARENT_NAME_SECTOR" class="java.lang.String"/>
<field name="AGENCY_PARENT_CODE" class="java.lang.String"/>
<field name="AGENCY_CODE" class="java.lang.String"/>
<field name="AGENCY_NAME" class="java.lang.String"/>
<field name="YEAR" class="java.math.BigDecimal"/>
<field name="SECTOR_ID" class="java.lang.String"/>
<field name="SECTOR_NAME" class="java.lang.String"/>
<field name="DYEAR1" class="java.math.BigDecimal"/>
<field name="DYEAR2" class="java.math.BigDecimal"/>
<field name="DYEAR3" class="java.math.BigDecimal"/>
<field name="DYEAR4" class="java.math.BigDecimal"/>
<field name="DYEAR5" class="java.lang.String"/>
<field name="YR1" class="java.math.BigDecimal"/>
<field name="YR2" class="java.math.BigDecimal"/>
<field name="YR3" class="java.math.BigDecimal"/>
<field name="YR4" class="java.math.BigDecimal"/>
<field name="YR5" class="java.math.BigDecimal"/>
<variable name="YR1_1" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR1}]]></variableExpression>
</variable>
<variable name="YR2_1" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR2}]]></variableExpression>
</variable>
<variable name="YR3_1" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR3}]]></variableExpression>
</variable>
<variable name="YR4_1" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR4}]]></variableExpression>
</variable>
<variable name="YR5_1" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR5}]]></variableExpression>
</variable>
<variable name="YR1_2" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR1}]]></variableExpression>
</variable>
<variable name="YR2_2" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR2}]]></variableExpression>
</variable>
<variable name="YR3_2" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR3}]]></variableExpression>
</variable>
<variable name="YR4_2" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR4}]]></variableExpression>
</variable>
<variable name="YR5_2" class="java.math.BigDecimal" resetType="Column" calculation="Sum">
<variableExpression><![CDATA[$F{YR5}]]></variableExpression>
</variable>
<variable name="sumA" class="java.lang.Integer" calculation="Sum">
<variableExpression><![CDATA[$F{YR1}+$F{YR2}+$F{YR3}+$F{YR4}+$F{YR5}]]></variableExpression>
</variable>
<group name="Agency">
<groupExpression><![CDATA[$F{PARENT_NAME_SECTOR}]]></groupExpression>
<groupHeader>
<band height="192">
<textField>
<reportElement x="622" y="83" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{SECTOR_NAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="64" y="145" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{AGENCY_NAME}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="74" y="83" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{DYEAR1}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="18" y="83" width="56" height="20"/>
<textElement/>
<text><![CDATA[Year From :]]></text>
</staticText>
<staticText>
<reportElement x="18" y="104" width="56" height="20"/>
<textElement/>
<text><![CDATA[Year To :]]></text>
</staticText>
<staticText>
<reportElement x="574" y="83" width="48" height="20"/>
<textElement/>
<text><![CDATA[Sector :]]></text>
</staticText>
<staticText>
<reportElement x="18" y="145" width="46" height="20"/>
<textElement/>
<text><![CDATA[Agency :]]></text>
</staticText>
<textField>
<reportElement x="74" y="104" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{DYEAR5}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="21" width="802" height="26"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[5 YEAR STATISTICS ON APPLICATION RECEIVED (BY ALL AGENCIES)]]></text>
</staticText>
<staticText>
<reportElement x="18" y="165" width="33" height="27"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[No.]]></text>
</staticText>
<textField>
<reportElement x="425" y="178" width="85" height="14"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{DYEAR3}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="510" y="178" width="85" height="14"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{DYEAR4}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="595" y="178" width="85" height="14"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{DYEAR5}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="340" y="178" width="85" height="14"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{DYEAR2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="255" y="178" width="85" height="14"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{DYEAR1}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="255" y="165" width="425" height="13"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Year]]></text>
</staticText>
<staticText>
<reportElement x="51" y="165" width="204" height="27"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<text><![CDATA[Agency Name]]></text>
</staticText>
<staticText>
<reportElement x="680" y="165" width="85" height="27"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[Total]]></text>
</staticText>
</band>
</groupHeader>
<groupFooter>
<band height="395">
<lineChart>
<chart>
<reportElement x="30" y="42" width="772" height="353"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<dataset resetType="Group" resetGroup="Agency" incrementType="Report"/>
<categorySeries>
<seriesExpression><![CDATA[$F{PARENT_NAME_SECTOR}]]></seriesExpression>
<categoryExpression><![CDATA[$F{YEAR}]]></categoryExpression>
<valueExpression><![CDATA[$F{YR5}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
</linePlot>
</lineChart>
<textField>
<reportElement x="340" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{YR2_2}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="18" y="0" width="237" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<text><![CDATA[ Total]]></text>
</staticText>
<textField>
<reportElement x="255" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{YR1_2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="425" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{YR3_2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="510" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{YR4_2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="595" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{YR5_2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="680" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[new Integer($V{YR1_1}.intValue() + $V{YR2_1}.intValue()+
$V{YR3_1}.intValue()+ $V{YR4_1}.intValue())+ $V{YR5_1}.intValue()]]></textFieldExpression>
</textField>
</band>
</groupFooter>
</group>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="510" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{YR4}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="51" y="0" width="204" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement>
<paragraph lineSpacing="Single"/>
</textElement>
<textFieldExpression><![CDATA[$F{PARENT_NAME_SECTOR}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="18" y="0" width="33" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$V{COLUMN_COUNT}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="255" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{YR1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="340" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{YR2}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="425" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{YR3}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="595" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[$F{YR5}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="680" y="0" width="85" height="20"/>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center"/>
<textFieldExpression><![CDATA[new Integer($F{YR1}.intValue() + $F{YR2}.intValue()+ $F{YR3}.intValue()+ $F{YR4}.intValue())+ $F{YR5}.intValue()]]></textFieldExpression>
</textField>
<break>
<reportElement x="0" y="19" width="802" height="1">
<printWhenExpression><![CDATA[($V{REPORT_COUNT} % 5 == 0)]]></printWhenExpression>
</reportElement>
</break>
</band>
</detail>
</jasperReport>