gpt4 book ai didi

jasper-reports - 如何在不重复页眉和页脚的情况下导出到 CSV?

转载 作者:行者123 更新时间:2023-12-04 17:36:28 32 4
gpt4 key购买 nike

我想导出到 CSV,页眉和页脚只显示一次

The current output:
Name Address Hobby
AAA US XXXXX
BBB UK XXXXX
(Footer)
Name Address Hobby
CCC ID XXXXX
DDD CC XXXXX
(Footer)
Name Address Hobby
EEE SA XXXXX
FFF ZM XXXXX
(Footer)

The desired output:
Name Address Hobby
AAA US XXXXX
BBB UK XXXXX
CCC ID XXXXX
DDD CC XXXXX
EEE SA XXXXX
FFF ZM XXXXX
(Footer)

那么如何让页眉和页脚只显示一次呢?

编辑:

页脚看起来像

版本:1.0.0
AcademicProgramBusinessEntityCentreDoma 执行时间:00:00:00.00
/NWU/StudentInformation/AcademicProgramDevelopment Build: v1.0.9 - Dev

最佳答案

您可以使用 net.sf.jasperreports.export.{format}.exclude.origin.{suffix}.{arbitrary_name} (有关详细信息,请参阅 http://jasperreports.sourceforge.net/config.reference.html 页面)属性用于排除带区(​​在您的情况下为页眉和页脚)对于导出商。

sample :

输入数据,csv文件(数据源):

AAA,US,XXXXX
BBB,UK,XXXXX
CCC,ID,XXXXX
DDD,CC,XXXXX
EEE,SA,XXXXX
FFF,ZM,XXXXX

jrxml 文件:

<?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="exclude_band_for_csv" language="groovy" pageWidth="595" pageHeight="120" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="0" bottomMargin="0" uuid="daaa60dc-b91b-4e9b-bbc0-6189af985ef9">
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.1" value="pageHeader"/>
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.2" value="pageFooter"/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="Name" class="java.lang.String"/>
<field name="Address" class="java.lang.String"/>
<field name="Hobby" class="java.lang.String"/>
<pageHeader>
<band height="35" splitType="Stretch">
<staticText>
<reportElement uuid="9da294e6-b5b7-489f-9469-7edb539315da" x="117" y="0" width="380" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Page Header]]></text>
</staticText>
</band>
</pageHeader>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement uuid="6a615d39-86f1-4a74-8ae7-4f8ca8e19afe" x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Name}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="df0929d2-34c0-4561-ab98-e6e5ce37fd11" x="100" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Address}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="675381d8-57b3-427f-88e4-ec4725ea3462" x="200" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{Hobby}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="45" splitType="Stretch">
<staticText>
<reportElement uuid="9da294e6-b5b7-489f-9469-7edb539315da" x="127" y="10" width="380" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="14"/>
</textElement>
<text><![CDATA[Page Footer]]></text>
</staticText>
</band>
</pageFooter>
</jasperReport>

iReport 中的报表设计:

Report's design in iReport

JRpdfExporter 的结果将是:

The result of generating the report in *PDF* format

两个波段都存在于 PDF 文件中

JRCsvExporter 的结果将是(输出 csv 文件):
AAA,US,XXXXX
BBB,UK,XXXXX
CCC,ID,XXXXX
DDD,CC,XXXXX
EEE,SA,XXXXX
FFF,ZM,XXXXX

CSV 文件中不存在这两个波段。

如您所见,我仅针对 JRCsvExporter 排除了两个波段(页眉和页脚)。

有关更多详细信息,您还可以查看此帖子: JasperReports: hide textfield when not HTML view

关于jasper-reports - 如何在不重复页眉和页脚的情况下导出到 CSV?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17426115/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com