作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我将 jrml 导出到 csv 和 pdf 时,我反复收到标题。
我想避免这种情况,请告诉我解决方案。
这是我的 JRML
<?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="Finance Report" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#F0F8FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="FinanceDataSet">
<queryString>
<![CDATA[]]>
</queryString>
<field name="additionName" class="java.lang.String">
<fieldDescription><![CDATA[additionName]]></fieldDescription>
</field>
<field name="cost" class="java.lang.String">
<fieldDescription><![CDATA[cost]]></fieldDescription>
</field>
<field name="projectNumber" class="java.lang.String">
<fieldDescription><![CDATA[projectNumber]]></fieldDescription>
</field>
<field name="projectType" class="java.lang.String">
<fieldDescription><![CDATA[projectType]]></fieldDescription>
</field>
<field name="sidNumber" class="java.lang.String">
<fieldDescription><![CDATA[sidNumber]]></fieldDescription>
</field>
<field name="softCost" class="java.lang.String">
<fieldDescription><![CDATA[softCost]]></fieldDescription>
</field>
<field name="yearContrbToAssests" class="java.lang.String">
<fieldDescription><![CDATA[yearContrbToAssests]]></fieldDescription>
</field>
</subDataset>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="68" splitType="Stretch">
<staticText>
<reportElement x="305" y="30" width="183" height="35"/>
<textElement textAlignment="Center">
<font size="24" isBold="true"/>
</textElement>
<text><![CDATA[Finance Report]]></text>
</staticText>
</band>
</title>
<pageHeader>
<band height="26" splitType="Stretch"/>
</pageHeader>
<detail>
<band height="125" splitType="Stretch">
<componentElement>
<reportElement key="table" style="table" x="60" y="0" width="267" height="85"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="FinanceDataSet">
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
</datasetRun>
<jr:column width="90">
<jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement key="col_header" x="0" y="0" width="90" height="30"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Project Number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="21" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="21"/>
<textElement/>
<textFieldExpression><![CDATA[$F{projectNumber}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement key="col_header" x="0" y="0" width="90" height="30"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Project Type]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="21" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{projectType}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement key="col_header" x="0" y="0" width="90" height="30"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Cost]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="21" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{cost}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement key="col_header" x="0" y="0" width="90" height="30"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Soft Cost]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="21" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{softCost}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90">
<jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement key="col_header" x="0" y="0" width="90" height="30"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Sid Number]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="21" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{sidNumber}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="143">
<jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement key="col_header" x="0" y="0" width="143" height="30"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Addition Name]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="21" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="143" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{additionName}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="113">
<jr:tableHeader style="table_TH" height="1" rowSpan="1"/>
<jr:columnHeader style="table_CH" height="30" rowSpan="1">
<staticText>
<reportElement key="col_header" x="0" y="0" width="110" height="30"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[YearContrbToAssests]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell style="table_TD" height="21" rowSpan="1">
<textField>
<reportElement x="0" y="0" width="113" height="21"/>
<textElement/>
<textFieldExpression><![CDATA[$F{yearContrbToAssests}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
outputStream = response.getOutputStream();
jasperReport = (JasperReport) JRLoader.loadObject(sourceFile);
jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(),jrDataSource);
jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.csv.exclude.origin.band.pageFooter", "pageFooter");
jasperPrint.getPropertiesMap().setProperty("net.sf.jasperreports.export.csv.exclude.origin.band.title", "title");
JRCsvExporter exporter = new JRCsvExporter();
exporter.setParameter(JRCsvExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRCsvExporterParameter.OUTPUT_STREAM, outputStream);
exporter.exportReport();
sourceFile = new File(request.getSession().getServletContext().getRealPath("WEB-INF/classes/Finance Report.jasper"));
response.setHeader("Content-Disposition", "attachment;filename=FinanceReport.pdf");
financeReportBeanList = (List<FinanceReportBean>) request.getSession().getAttribute("financeReportList");
financeReportBeanList.get(0).setCurrentDate(DateUtil.getCurrentDate());
jrDataSource = new JRBeanCollectionDataSource(financeReportBeanList);
JasperReport jasperReport=null;
JasperPrint jasperPrint=null;
OutputStream outputStream=null;
outputStream = response.getOutputStream();
jasperReport = (JasperReport) JRLoader.loadObject(sourceFile);
jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(),jrDataSource);
JRPdfExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
exporter.exportReport();
最佳答案
如图所示在 jrxml 中添加以下两个属性,这将排除 pageHeader
来自 csv
和 pdf
格式。
<property name="net.sf.jasperreports.export.csv.exclude.origin.keep.first.band.1" value="pageHeader"/>
<property name="net.sf.jasperreports.export.pdf.exclude.origin.keep.first.band.2" value="pageHeader"/>
<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="Finance Report" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
--> <property name="net.sf.jasperreports.export.csv.exclude.origin.keep.first.band.1" value="pageHeader"/>
--> <property name="net.sf.jasperreports.export.pdf.exclude.origin.keep.first.band.2" value="pageHeader"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
key
给您的
columnHeader
如下图:
<jr:columnHeader style="table_CH" height="30" rowSpan="1" key="col_header">
property
隐藏它。
<property name="net.sf.jasperreports.export.csv.exclude.key.col_header"/>
关于java - 如何删除JR报告中除第一页外的所有页面中表格组件的表头?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18527720/
SCENARIO 有两页,第一页是HomePage,它在flutter_bloc软件包的帮助下自动获取api数据。在首页(第一页)中,还有一个按钮,可在此代码Navigator.push(contex
我检查过类似的问题,但由其他人发布,但我仍然看不到我的代码有什么问题。 我刚刚从文档中复制了它 - https://symfony.com/doc/3.4/page_creation.html Luc
我已经编写了一段代码,使用Python中的Scrapy来抓取页面。下面我粘贴了 main.py 代码。但是,每当我运行我的蜘蛛时,它仅从第一页抓取(DEBUG:从抓取),这也是请求中的Referer标
我创建了一个 ios 图书阅读器应用程序。在这个应用程序中,我集成了 google drive 和 skydrive 。现在我可以从 google drive 和 skydrive 登录和检索数据了。
效果图: 功能简介:可使用上下键选中行,选中后点击修改,textbox获得gridview中的代码的数据。对你有帮助的话,请记得要点击“好文要顶”哦!!!不懂的,请留言。废话不多说了,贴码如下
我是一名优秀的程序员,十分优秀!