Jasper Report Engine

Jasper Report Engine is an open-sourced tool. You can define jrxml template by iReport designer.

Java Code:

JasperReport jasperReport = JasperCompileManager.compileReport("D:/test.jrxml");
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("htmlContent", getTestString());
JasperPrint jasperPrint = JasperFillManager.
fillReport(jasperReport, parameters,new JREmptyDataSource());
JasperExportManager.exportReportToPdfFile(jasperPrint,"D:/test.pdf");



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="TEMIP0006" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<parameter name="minutesContent" class="java.lang.String"/>

<pageHeader>
<band height="61" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement x="37" y="0" width="383" height="42"/>
<textElement lineSpacing="Single">
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["page header"]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="61" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement x="37" y="0" width="383" height="42"/>
<textElement lineSpacing="Single">
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["column header"]]></textFieldExpression>
</textField>
</band>
</columnHeader>
<detail>
<band height="540">
<textField isStretchWithOverflow="true" evaluationTime="Now" pattern="" isBlankWhenNull="true">
<reportElement key="element-1" mode="Opaque" x="68" y="0" width="487" height="500" isPrintWhenDetailOverflows="true" forecolor="#0FFF00" backcolor="#FFFFFF"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single" markup="html">
<font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["<html>" +
"<body>" +
(($P{htmlContent} != null) ? String.valueOf($P{htmlContent}) : "") +
"</body>" +
"</html>"]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="40" y="0" width="11" height="15"/>
<textElement textAlignment="Right"/>
<text><![CDATA[:]]></text>
</staticText>
<staticText>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="42" height="15"/>
<textElement>
<font fontName="Arial"/>
</textElement>
<text><![CDATA[Content]]></text>
</staticText>
</band>
</detail>
<columnFooter>
<band height="61" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement x="37" y="0" width="383" height="42"/>
<textElement lineSpacing="Single">
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["column footer"]]></textFieldExpression>
</textField>
</band>
</columnFooter>
<pageFooter>
<band height="61" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement x="37" y="0" width="383" height="42"/>
<textElement lineSpacing="Single">
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["page footer"]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="61" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement x="37" y="0" width="383" height="42"/>
<textElement lineSpacing="Single">
<font fontName="Arial" size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["summary"]]></textFieldExpression>
</textField>
</band>
</summary>
</jasperReport>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值