Jasper报告导出到RTF无法正常工作

时间:2016-03-23 12:43:04

标签: jasper-reports rtf

我正在使用jrxml导出为RTF格式。 当列数为12时,它工作正常,否则如果我们增加列数视图似乎失真。

当我用10列导出时,它看起来非常好。

我是新手,在这种情况下,任何人都可以帮助我。

使用的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="PSDefaultPointAndClick" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20">
	<property name="ireport.scriptlethandling" value="0"/>
	<property name="ireport.encoding" value="UTF-8"/>
	<property name="ireport.zoom" value="1.4641000000000006"/>
	<property name="ireport.x" value="0"/>
	<property name="ireport.y" value="0"/>
	<import value="net.sf.jasperreports.engine.*"/>
	<import value="java.util.*"/>
	<import value="net.sf.jasperreports.engine.data.*"/>
	<parameter name="system.REPORT_NAME" class="java.lang.String" isForPrompting="false">
		<defaultValueExpression><![CDATA["Default Report"]]></defaultValueExpression>
	</parameter>
	<parameter name="config.SUPPORTED_FORMATS" class="java.lang.String" isForPrompting="false">
		<defaultValueExpression><![CDATA["HTML,PDF,EXCEL,EXCEL_2007,RTF,CSV,POWERPOINT_2007"]]></defaultValueExpression>
	</parameter>
	<parameter name="config.FOR_INTERNAL_USE" class="java.lang.String" isForPrompting="false"/>
	<parameter name="system.REPORT_FOOTER" class="java.lang.String" isForPrompting="false">
		<defaultValueExpression><![CDATA["Copyright (c) 2007,"]]></defaultValueExpression>
	</parameter>
	<parameter name="config.DATASOURCE" class="java.lang.String" isForPrompting="false">
		<defaultValueExpression><![CDATA["PointAndClick"]]></defaultValueExpression>
	</parameter>
	<parameter name="system.RUN_BY_AND_ON_INFO" class="java.lang.String" isForPrompting="false"/>
	<parameter name="system.GENERATION_DATE" class="java.lang.String" isForPrompting="false"/>
	<parameter name="system.USER_NAME" class="java.lang.String" isForPrompting="false"/>
	<parameter name="system.PAGE" class="java.lang.String" isForPrompting="false"/>
	<parameter name="system.EXPORT_FORMAT" class="java.lang.String" isForPrompting="false"/>
	<field name="work_id" class="java.lang.String"/>
	<field name="name" class="java.lang.String"/>
	<field name="owner" class="java.lang.String"/>
	<field name="owner_id" class="java.lang.String"/>
	<field name="status_current" class="java.lang.String"/>
	<field name="active_gate" class="java.lang.String"/>
	<field name="active_gate_id" class="java.lang.String"/>
	<group name="level1">
		<groupExpression><![CDATA[]]></groupExpression>
		<groupHeader>
			<band height="16" splitType="Prevent">
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement key="textField-12" stretchType="RelativeToBandHeight" mode="Opaque" x="54" y="0" width="341" height="16" backcolor="#EBEBEB"/>
					<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
						<pen lineWidth="0.0"/>
						<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<leftPen lineWidth="0.0"/>
						<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<rightPen lineWidth="0.0"/>
					</box>
					<textElement verticalAlignment="Bottom">
						<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA["Group Level 1 "]]></textFieldExpression>
				</textField>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="20" splitType="Prevent">
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement key="textField-22" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="395" height="16" backcolor="#FFFFFF"/>
					<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
						<pen lineWidth="0.0"/>
						<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<leftPen lineWidth="0.0"/>
						<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<rightPen lineWidth="0.0"/>
					</box>
					<textElement>
						<font fontName="Arial" isBold="true" isItalic="false" pdfFontName="Helvetica-Bold" size="9"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA["Summary Level 1 "]]></textFieldExpression>
				</textField>
			</band>
		</groupFooter>
	</group>
	<group name="level2">
		<groupExpression><![CDATA[]]></groupExpression>
		<groupHeader>
			<band height="16" splitType="Prevent">
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement key="textField-13" stretchType="RelativeToBandHeight" mode="Opaque" x="99" y="0" width="296" height="16" backcolor="#EBEBEB"/>
					<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
						<pen lineWidth="0.0"/>
						<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<leftPen lineWidth="0.0"/>
						<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<rightPen lineWidth="0.0"/>
					</box>
					<textElement verticalAlignment="Bottom">
						<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA["Group Level 2 "]]></textFieldExpression>
				</textField>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="20" splitType="Prevent">
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement key="textField-21" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="395" height="16" backcolor="#FFFFFF"/>
					<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
						<pen lineWidth="0.0"/>
						<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<leftPen lineWidth="0.0"/>
						<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<rightPen lineWidth="0.0"/>
					</box>
					<textElement>
						<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA["Summary Level 2 "]]></textFieldExpression>
				</textField>
			</band>
		</groupFooter>
	</group>
	<group name="level3">
		<groupExpression><![CDATA[]]></groupExpression>
		<groupHeader>
			<band height="16" splitType="Prevent">
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement key="textField-14" stretchType="RelativeToBandHeight" mode="Opaque" x="158" y="0" width="237" height="16" backcolor="#EBEBEB"/>
					<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
						<pen lineWidth="0.0"/>
						<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<leftPen lineWidth="0.0"/>
						<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<rightPen lineWidth="0.0"/>
					</box>
					<textElement verticalAlignment="Bottom">
						<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA["Group Level 3 "]]></textFieldExpression>
				</textField>
			</band>
		</groupHeader>
		<groupFooter>
			<band height="20" splitType="Prevent">
				<textField isStretchWithOverflow="true" isBlankWhenNull="true">
					<reportElement key="textField-20" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="395" height="16"/>
					<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
						<pen lineWidth="0.0"/>
						<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<leftPen lineWidth="0.0"/>
						<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
						<rightPen lineWidth="0.0"/>
					</box>
					<textElement>
						<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
					</textElement>
					<textFieldExpression class="java.lang.String"><![CDATA["Summary Level 3 "]]></textFieldExpression>
				</textField>
			</band>
		</groupFooter>
	</group>
	<background>
		<band splitType="Stretch"/>
	</background>
	<title>
		<band splitType="Stretch"/>
	</title>
	<pageHeader>
		<band splitType="Stretch"/>
	</pageHeader>
	<columnHeader>
		<band height="16" splitType="Prevent">
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField-4" stretchType="RelativeToTallestObject" mode="Opaque" x="0" y="0" width="395" height="16" backcolor="#E7EFF7"/>
				<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
					<leftPen lineWidth="1.0" lineColor="#FFFFFF"/>
					<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
					<rightPen lineWidth="1.0" lineColor="#FFFFFF"/>
				</box>
				<textElement verticalAlignment="Bottom">
					<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["ColumnTitle"]]></textFieldExpression>
			</textField>
		</band>
	</columnHeader>
	<detail>
		<band height="16" splitType="Prevent">
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField-11" stretchType="RelativeToBandHeight" mode="Opaque" x="235" y="0" width="160" height="16"/>
				<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2"/>
				<textElement>
					<font fontName="Arial" isBold="false" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Even_Row"]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField-16" stretchType="RelativeToBandHeight" mode="Opaque" x="395" y="0" width="140" height="16" backcolor="#FCFAF6"/>
				<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2"/>
				<textElement>
					<font fontName="Arial" isBold="false" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Odd_Row"]]></textFieldExpression>
			</textField>
		</band>
	</detail>
	<columnFooter>
		<band height="20" splitType="Prevent">
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField-17" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="395" height="16"/>
				<box topPadding="1" leftPadding="2" bottomPadding="1" rightPadding="2">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
					<leftPen lineWidth="0.0"/>
					<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
					<rightPen lineWidth="0.0"/>
				</box>
				<textElement>
					<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Column Summary"]]></textFieldExpression>
			</textField>
		</band>
	</columnFooter>
	<pageFooter>
		<band height="42" splitType="Prevent">
			<textField isStretchWithOverflow="true" isBlankWhenNull="false">
				<reportElement key="textField-26" mode="Opaque" x="0" y="6" width="58" height="36" backcolor="#F5F5F5"/>
				<box topPadding="3" bottomPadding="2">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font fontName="Arial" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$P{system.PAGE} + " " + $V{PAGE_NUMBER} + " /"]]></textFieldExpression>
			</textField>
			<textField evaluationTime="Report" isBlankWhenNull="false">
				<reportElement key="textField-27" mode="Opaque" x="58" y="6" width="59" height="36" backcolor="#F5F5F5"/>
				<box topPadding="3" bottomPadding="2">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font fontName="Arial" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="false">
				<reportElement key="textField-28" mode="Opaque" x="117" y="6" width="418" height="36" backcolor="#F5F5F5"/>
				<box topPadding="3" bottomPadding="2" rightPadding="9">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font fontName="Arial" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$P{system.REPORT_FOOTER}]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
	<lastPageFooter>
		<band height="38" splitType="Stretch">
			<textField isStretchWithOverflow="true" isBlankWhenNull="false">
				<reportElement key="textField-23" mode="Opaque" x="0" y="2" width="58" height="36" backcolor="#F5F5F5"/>
				<box topPadding="3" bottomPadding="2">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font fontName="Arial" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$P{system.PAGE} + " " + $V{PAGE_NUMBER} + " /"]]></textFieldExpression>
			</textField>
			<textField evaluationTime="Report" isBlankWhenNull="false">
				<reportElement key="textField-24" mode="Opaque" x="58" y="2" width="59" height="36" backcolor="#F5F5F5"/>
				<box topPadding="3" bottomPadding="2">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement verticalAlignment="Middle">
					<font fontName="Arial" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<textField isBlankWhenNull="false">
				<reportElement key="textField-25" mode="Opaque" x="117" y="2" width="418" height="36" backcolor="#F5F5F5"/>
				<box topPadding="3" bottomPadding="2" rightPadding="9">
					<pen lineWidth="0.0"/>
					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
					<bottomPen lineWidth="0.0" lineColor="#000000"/>
					<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
				</box>
				<textElement textAlignment="Right" verticalAlignment="Middle">
					<font fontName="Arial" pdfFontName="Helvetica" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$P{system.REPORT_FOOTER}]]></textFieldExpression>
			</textField>
		</band>
	</lastPageFooter>
	<summary>
		<band height="16" splitType="Stretch">
			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
				<reportElement key="textField-18" stretchType="RelativeToBandHeight" mode="Opaque" x="0" y="0" width="535" height="16"/>
				<box>
					<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
					<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#FFFFFF"/>
				</box>
				<textElement>
					<font fontName="Arial" isBold="true" pdfFontName="Helvetica-Bold" size="9"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA["Root Summary"]]></textFieldExpression>
			</textField>
		</band>
	</summary>
</jasperReport>
&#13;
&#13;
&#13;

JRXML文件:

https://www.dropbox.com/s/l866uv4z7sccf2c/12columns.jrxml?dl=0

Screenshot after exporting to RTF

1 个答案:

答案 0 :(得分:0)

您无法创建页面大小超过22英寸的RTF文档。 您的报告模板宽度为23.11英寸。 我能找到的最好的解释是here