2

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

我尝试使用溢出属性和拉伸没有结果。

编辑(来自评论的澄清):GenericJon 响应很有用,但是,在使用 jasper 导出器构建文档时是否可以设置此 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>

这是我应该在构建后轻松自定义的结果文档。 去下载文件

4

2 回答 2

3

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

<?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"/>

更多房产信息: 链接

注意:您应该考虑范式,报告是“只读的”。因此,用户应该将数据填写到一些程序化表格中,然后生成报告......

于 2013-08-21T13:10:11.653 回答
1

JasperReports 通过使用表格来实现文档的布局。在 MS Word 中,您应该能够通过选择Table Tools > Layout > Show Gridlines来看到这一点。所有行都有特定的固定高度,因此当您添加超出单元格大小的更多内容时,它将不可见。

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

于 2013-08-21T09:25:12.577 回答