在构建按ENTER键后,无法将新段落添加到Jasper Report文档中

时间:2013-08-21 08:09:16

标签: jasper-reports

我需要生成一个jasper文档,该文档可由用户使用Microsoft Word构建后编辑。我遇到的问题是,一旦我生成文档,我就无法使用 ENTER 键在现有文档之间添加新段落。发生的事情是文本消失在后面的段落中,隐藏在。

之下

我尝试使用overflow属性并伸展没有结果。

编辑(来自评论的澄清):GenericJon响应很有用但是,可以在使用jasper exporter构建文档时设置此Microsoft Word属性,以便使用此单元格高度属性打开文档设置好的?

提前致谢!

我的java应用程序使用 jasperreports-4.5.1.jar 我正在使用 Jaspersoft iReport Designer 5.0.4 编译我的模板 我使用 Microsoft Word 2013 在构建后编辑文档。

以下是XML报告:

<?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="SolicitudPresupuestoCM" pageWidth="595" pageHeight="842" columnWidth="475" leftMargin="60" rightMargin="60" topMargin="20" bottomMargin="20" whenResourceMissingType="Key" uuid="255a457f-fbfa-4352-8d45-fb04f539febb">
    <property name="ireport.zoom" value="1.2396694214876032"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="ireport.scriptlethandling" value="0"/>
    <property name="ireport.encoding" value="UTF-8"/>
    <import value="net.sf.jasperreports.engine.*"/>
    <import value="java.util.*"/>
    <import value="net.sf.jasperreports.engine.data.*"/>
    <parameter name="DIRECTORIO_IMAGENES" class="java.lang.String" isForPrompting="false"/>
    <parameter name="fechaPropuesta" class="java.util.Date" isForPrompting="false"/>
    <parameter name="numParrafosPrimerTexto" class="java.lang.Integer" isForPrompting="false"/>
    <parameter name="nombreFirma" class="java.lang.String" isForPrompting="false"/>
    <parameter name="cargoFirma" class="java.lang.String" isForPrompting="false"/>
    <parameter name="expediente" class="java.lang.String" isForPrompting="false"/>
    <parameter name="objeto" class="java.lang.String" isForPrompting="false"/>
    <parameter name="aplicacionPresupuestaria" class="java.lang.String" isForPrompting="false"/>
    <parameter name="importe" class="java.lang.String" isForPrompting="false"/>
    <parameter name="empresa" class="java.lang.String" isForPrompting="false"/>
    <parameter name="cif" class="java.lang.String" isForPrompting="false"/>
    <parameter name="numFactura" class="java.lang.String" isForPrompting="false"/>
    <queryString language="SQL">
        <![CDATA[]]>
    </queryString>
    <field name="texto" class="java.lang.String"/>
    <variable name="index" class="java.lang.Integer" incrementType="Report">
        <variableExpression><![CDATA[Integer.valueOf($V{index}.intValue() + 1)]]></variableExpression>
        <initialValueExpression><![CDATA[Integer.valueOf(0)]]></initialValueExpression>
    </variable>
    <pageHeader>
        <band height="101" splitType="Stretch">
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="dfc390b7-4917-47da-970f-d9e69de9626d" x="355" y="79" width="121" height="14"/>
                <textElement>
                    <font fontName="Arial" size="8" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{expediente}]]></textFieldExpression>
            </textField>
        </band>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="23" splitType="Stretch">
            <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false">
                <reportElement uuid="4fb4251a-765e-47b6-bd8d-60690d8df47a" x="0" y="0" width="475" height="10" isRemoveLineWhenBlank="true"/>
                <textElement textAlignment="Justified">
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{texto}]]></textFieldExpression>
            </textField>
        </band>
        <band height="73" splitType="Stretch">
            <staticText>
                <reportElement uuid="d0ec9d8d-de99-4b1f-a5f2-bd43b7ddd478" isPrintRepeatedValues="false" x="0" y="0" width="221" height="14" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[OBJECT: Payment of the invoice number]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="f8151046-97b5-452c-9423-50eea1b9f5d3" isPrintRepeatedValues="false" x="0" y="14" width="60" height="14" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[AMOUNT:]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="2fa9090a-0ecd-4084-8947-48bfc161bd16" isPrintRepeatedValues="false" x="0" y="28" width="73" height="15" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[APLICATION:]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="3abdff65-88a4-4201-af12-2d89c9e9b2cd" isPrintRepeatedValues="false" x="0" y="43" width="100" height="15" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[BIDDER:]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="eecdd67b-eb52-47e3-ae9e-fd5be9f0578e" isPrintRepeatedValues="false" x="335" y="43" width="47" height="15" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[NIF/CIF:]]></text>
            </staticText>
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="45e2af4d-aa76-4d8a-b736-09b9298b24c1" isPrintRepeatedValues="false" x="60" y="14" width="415" height="14" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{importe}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="0a69cee5-7970-4972-9b74-ebc4fe6687d5" isPrintRepeatedValues="false" x="77" y="28" width="306" height="15" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{aplicacionPresupuestaria}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="ea832f4b-30cd-4240-84dd-c39a01674540" isPrintRepeatedValues="false" x="100" y="43" width="235" height="15" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{empresa}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="291d18a5-4e09-41af-81ef-38da536f868b" isPrintRepeatedValues="false" x="383" y="43" width="92" height="15" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{cif}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement uuid="15cc14e4-06ec-4c5f-92ff-5f7261bc83f8" isPrintRepeatedValues="false" x="221" y="0" width="58" height="14" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{numFactura}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement uuid="9e5ab1d9-008f-44c5-b25a-c95184f1ff1b" isPrintRepeatedValues="false" x="279" y="0" width="86" height="14" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[realtive to]]></text>
            </staticText>
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="7c57f57d-033d-4e85-8f18-d2f40521e5b3" isPrintRepeatedValues="false" x="365" y="0" width="110" height="14" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfFontName="Arial" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{objeto}]]></textFieldExpression>
            </textField>
        </band>
        <band height="85" splitType="Stretch">
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="386f28db-aa1e-46e8-8c31-dd01a5c041c8" x="0" y="20" width="475" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{cargoFirma}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement uuid="d4e52606-aaf0-48a8-8dd3-b1532b0f5eed" key="staticText" isPrintRepeatedValues="false" x="0" y="0" width="135" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[Somewhere,]]></text>
            </staticText>
            <textField isStretchWithOverflow="true" isBlankWhenNull="false">
                <reportElement uuid="a8ceb09b-bc70-4875-90de-877cf9889351" isPrintRepeatedValues="false" x="0" y="65" width="475" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{nombreFirma}]]></textFieldExpression>
            </textField>
            <textField pattern="dd/MM/yyyy" isBlankWhenNull="false">
                <reportElement uuid="71a758b9-a5bc-4890-ae2f-74263245d0c4" isPrintRepeatedValues="false" x="135" y="0" width="220" height="20" isRemoveLineWhenBlank="true">
                    <printWhenExpression><![CDATA[Boolean.valueOf(($V{index} == $P{numParrafosPrimerTexto}))]]></printWhenExpression>
                </reportElement>
                <textElement>
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA[$P{fechaPropuesta}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="122">
            <staticText>
                <reportElement uuid="47118a66-c23c-4b35-b90f-7e469eb97a99" key="staticText" x="0" y="0" width="73" height="20"/>
                <textElement>
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[Otherwhere,]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="880fd5a8-8a35-49d2-b226-5413d7d02120" key="staticText" x="0" y="20" width="475" height="20"/>
                <textElement>
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[The director of ...]]></text>
            </staticText>
            <staticText>
                <reportElement uuid="6a5f6b70-0574-4c6f-8e44-09356eda2a51" key="staticText" x="0" y="71" width="475" height="20"/>
                <textElement>
                    <font fontName="Arial" size="11" pdfEncoding="Cp1252" isPdfEmbedded="true"/>
                </textElement>
                <text><![CDATA[Charles Irwin]]></text>
            </staticText>
        </band>
    </pageFooter>
</jasperReport>

这是我应该在构建后轻松自定义的结果文档。 Go to download document

2 个答案:

答案 0 :(得分:3)

当您将net.sf.jasperreports.export.docx.flexible.row.height属性添加到具有true值的报告时,该行将在您写入时重新调整大小。

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ...>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="net.sf.jasperreports.export.docx.flexible.row.height" value="true"/>

有关物业的更多信息: Link

注意:您应该考虑范例,报告是“只读”。因此,用户应将数据填充到某种程序化形式,然后生成报告......

答案 1 :(得分:1)

JasperReports通过使用表来实现文档的布局。在MS Word中,您应该可以通过选择表格工具&gt;来看到这一点。布局&gt;显示网格线。所有行都具有特定的固定高度,因此当您添加超出单元格大小的内容时,它将不可见。

要在添加新段落时启用单元格增长,请在要添加内容的单元格内右键单击,然后选择表格属性... 。在标签上,取消选中指定高度旁边的框。然后应增加行高以容纳内容。