我正在使用 Jasper Reports 生成报告。我已经定义了自己的样式以应用于 jrtx 文件中的报告,并且我通过从 Java 程序传递参数来调用 jrtx 文件。它适用于嵌入在 jrtx 文件中的单一样式。我有 3 种不同的风格来申请所有的报告。我在 jrtx 文件中定义了所有 3 种样式。我的问题是只有 jrtx 中定义的第一个样式被应用。如何使所有 3 种不同的样式都适用于报告的不同部分?
我的 StyleTemplate1.jrtx
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperTemplate PUBLIC "-//JasperReports//DTD Template//EN" "http://jasperreports.sourceforge.net/dtds/jaspertemplate.dtd">
<jasperTemplate>
<style name="ColumnHeader" isDefault="true" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
<style name="ColumnText" fontSize="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
<style name="TitleHeader" fontSize="14" isItalic="true" isUnderline="true" isStrikeThrough="true"/>
</jasperTemplate>
我的 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="OPRS_Corporations" language="groovy" pageWidth="895" pageHeight="792" whenNoDataType="AllSectionsNoDetail" columnWidth="750" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isIgnorePagination="true">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<template><![CDATA[$P{TEMPLATE_FILE}]]></template>
<parameter name="CompanyName" class="java.lang.String"/>
<parameter name="Address1" class="java.lang.String"/>
<parameter name="Email" class="java.lang.String"/>
<parameter name="FaxNo" class="java.lang.String"/>
<parameter name="TelNo" class="java.lang.String"/>
<parameter name="WebAddress" class="java.lang.String"/>
<parameter name="pCorpCode" class="java.lang.String"/>
<parameter name="pCorpName" class="java.lang.String"/>
<parameter name="LogoBaseDIR" class="java.lang.String"/>
<parameter name="pLoginName" class="java.lang.String"/>
<parameter name="pRoleName" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String"/>
<parameter name="pEmail" class="java.lang.String"/>
<parameter name="TEMPLATE_FILE" class="java.lang.String"/>
<queryString>
<![CDATA[SELECT
CORP_ID
, CORP_CODE
, HEAD_OFFICE
, CORP_NAME
, EMAIL
, STATE_CODE
, CREATED_BY
, CREATED_DATE
, MODIFIED_BY
, MODIFIED_DATE
FROM OPRS_CORPORATION]]>
</queryString>
<field name="CORP_ID" class="java.math.BigDecimal"/>
<field name="CORP_CODE" class="java.lang.String"/>
<field name="HEAD_OFFICE" class="java.lang.String"/>
<field name="CORP_NAME" class="java.lang.String"/>
<field name="EMAIL" class="java.lang.String"/>
<field name="STATE_CODE" class="java.lang.String"/>
<field name="CREATED_BY" class="java.math.BigDecimal"/>
<field name="CREATED_DATE" class="java.sql.Timestamp"/>
<field name="MODIFIED_BY" class="java.math.BigDecimal"/>
<field name="MODIFIED_DATE" class="java.sql.Timestamp"/>
<filterExpression><![CDATA[($P{pCorpCode}.isEmpty()
|| $F{CORP_CODE}.equals( $P{pCorpCode} )
) &&
($P{pCorpName}.isEmpty()
|| $F{CORP_NAME}.contains( $P{pCorpName} )
)]]></filterExpression>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="81" splitType="Stretch">
<subreport>
<reportElement x="1" y="1" width="854" height="36"/>
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<subreportParameter name="CompanyName">
<subreportParameterExpression><![CDATA[$P{CompanyName}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="Address1">
<subreportParameterExpression><![CDATA[$P{Address1}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="Email">
<subreportParameterExpression><![CDATA[$P{Email}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="FaxNo">
<subreportParameterExpression><![CDATA[$P{FaxNo}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="TelNo">
<subreportParameterExpression><![CDATA[$P{TelNo}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="WebAddress">
<subreportParameterExpression><![CDATA[$P{WebAddress}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="LogoBaseDIR">
<subreportParameterExpression><![CDATA[$P{LogoBaseDIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "OPRS_Header.jasper"]]></subreportExpression>
</subreport>
<staticText>
<reportElement mode="Transparent" x="201" y="37" width="407" height="20"/>
<textElement textAlignment="Center">
<font size="14" isBold="true" isUnderline="false"/>
</textElement>
<text><![CDATA[CORPORATIONS]]></text>
</staticText>
<textField evaluationTime="Report" pattern="dd/MM/yyyy HH:mm:ss" isBlankWhenNull="true">
<reportElement x="719" y="59" width="136" height="20"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy HH.mm.ss">
<reportElement x="529" y="59" width="190" height="20"/>
<textElement textAlignment="Right">
<font size="12" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{pLoginName}+"("+$P{pRoleName}+") / "]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="57" width="855" height="1"/>
</line>
</band>
</title>
<columnHeader>
<band height="18" splitType="Stretch">
<staticText>
<reportElement x="186" y="0" width="233" height="17"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[CORP NAME]]></text>
</staticText>
<staticText>
<reportElement x="420" y="0" width="130" height="17"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[HEAD OFFICE]]></text>
</staticText>
<staticText>
<reportElement x="738" y="0" width="118" height="17"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[STATE CODE]]></text>
</staticText>
<staticText>
<reportElement x="48" y="0" width="136" height="17"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[CORP CODE]]></text>
</staticText>
<staticText>
<reportElement x="2" y="0" width="45" height="18"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[S.No]]></text>
</staticText>
<staticText>
<reportElement x="551" y="0" width="186" height="17"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[EMAIL]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement x="48" y="0" width="136" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{CORP_CODE}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="186" y="0" width="233" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{CORP_NAME}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement x="420" y="0" width="130" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{HEAD_OFFICE}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="752" y="0" width="103" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{STATE_CODE}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="2" width="47" height="18"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="551" y="1" width="186" height="19"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{EMAIL}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
任何想法表示赞赏。
谢谢