无法通过JasperReports打印PDF中的空单元格边框

时间:2014-10-09 13:32:41

标签: jasper-reports pdf-generation

我正在制作一张桌子'通过让细胞彼此相邻而且它们都有边界。但我有一个问题,即边界不会显示工作代码文本的单元格是否有值。

这是我的jrxml - (它是一个子报告,所以我有一个额外的数据集,并且workcodeText以这种方式处理,因为我不知道我将在xml数据中有多少个工作代码文本节点。)< / p>

<?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="estimate-subreport" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" scriptletClass="com.cybage.mo.CostCalculation" uuid="2df6e224-aab9-42e3-a97c-aa614b05982c">
<property name="ireport.zoom" value="1.5"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="Normal-Text-Small" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false">
    <box leftPadding="1" rightPadding="1"/>
</style>
<style name="Normal-Text-Small-with-borders" style="Normal-Text-Small" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false">
    <box leftPadding="1" rightPadding="1">
        <pen lineWidth="0.5" lineColor="#000000"/>
        <topPen lineWidth="0.5" lineColor="#000000"/>
        <leftPen lineWidth="0.5" lineColor="#000000"/>
        <bottomPen lineWidth="0.5" lineColor="#000000"/>
        <rightPen lineWidth="0.5" lineColor="#000000"/>
    </box>
</style>
<style name="Normal-Text-Small-bold" style="Normal-Text-Small" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false">
    <box leftPadding="1" rightPadding="1"/>
</style>
<style name="Normal-Text-Small-bold-with-borders" style="Normal-Text-Small-bold" hAlign="Left" vAlign="Top" fontName="Calibri" fontSize="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false">
    <box leftPadding="1" rightPadding="1">
        <pen lineColor="#000000"/>
        <topPen lineWidth="0.5" lineColor="#000000"/>
        <leftPen lineWidth="0.5" lineColor="#000000"/>
        <bottomPen lineWidth="0.5" lineColor="#000000"/>
        <rightPen lineWidth="0.5" lineColor="#000000"/>
    </box>
</style>
<subDataset name="WorkcodeText" uuid="3615899a-9e63-45db-a26e-d4e6d1670f84">
    <queryString language="xPath">
        <![CDATA[/MCSResponse/EstimateDisplayResponse/CategoryDetail/WorkcodeDetail/WorkcodeText]]>
    </queryString>
    <field name="WorkcodeText" class="java.lang.String">
        <fieldDescription><![CDATA[child::text()]]></fieldDescription>
    </field>
    <field name="last_wct" class="java.lang.String">
        <fieldDescription><![CDATA[../WorkcodeText[last()]]]></fieldDescription>
    </field>
    <field name="WorkcodeAmount" class="java.lang.String">
        <fieldDescription><![CDATA[/MCSResponse/EstimateDisplayResponse/CategoryDetail/WorkcodeDetail/WorkcodeAmount]]></fieldDescription>
    </field>
    <variable name="varWorkcodeText" class="java.lang.String">
        <variableExpression><![CDATA[$V{varWorkcodeText}+($F{WorkcodeText} != null? $F{WorkcodeText}:" test ")]]></variableExpression>
        <initialValueExpression><![CDATA[""]]></initialValueExpression>
    </variable>
</subDataset>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
    <defaultValueExpression><![CDATA["D:\\iReport\\Saquib\\Single_Estimate_Report\\Test\\"]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
    <![CDATA[CategoryDetail/WorkcodeDetail]]>
</queryString>
<field name="Workcode" class="java.lang.String">
    <fieldDescription><![CDATA[Workcode]]></fieldDescription>
</field>
<field name="WorkcodeName" class="java.lang.String">
    <fieldDescription><![CDATA[WorkcodeName]]></fieldDescription>
</field>
<field name="ExtraWorkcodeName" class="java.lang.String">
    <fieldDescription><![CDATA[ExtraWorkcodeName]]></fieldDescription>
</field>
<field name="WorkcodeAmount" class="java.lang.String">
    <fieldDescription><![CDATA[WorkcodeAmount]]></fieldDescription>
</field>
<field name="WorkcodeText" class="java.lang.String">
    <fieldDescription><![CDATA[WorkcodeText]]></fieldDescription>
</field>
<field name="ItemDetail" class="java.lang.String">
    <fieldDescription><![CDATA[ItemDetail]]></fieldDescription>
</field>
<detail>
    <band height="15">
        <componentElement>
            <reportElement positionType="Float" stretchType="RelativeToTallestObject" x="150" y="0" width="300" height="15" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" uuid="6b4ddd03-9978-4f83-a247-3fff22149cb1"/>
            <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
                <datasetRun subDataset="WorkcodeText" uuid="7aeae23c-e1fe-4470-9ee5-98f84cd82159">
                    <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//WorkcodeText")]]></dataSourceExpression>
                </datasetRun>
                <jr:listContents height="15" width="300">
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement style="Normal-Text-Small-with-borders" positionType="Float" stretchType="RelativeToTallestObject" mode="Transparent" x="0" y="0" width="300" height="15" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true" forecolor="#0000FF" uuid="03dd8f13-7604-41be-9155-ae02aa44500e">
                            <printWhenExpression><![CDATA[$F{WorkcodeText}.equals($F{last_wct})]]></printWhenExpression>
                        </reportElement>
                        <textElement verticalAlignment="Top">
                            <font size="9"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$V{varWorkcodeText}.replaceAll(  "<nl>", "\n" )]]></textFieldExpression>
                    </textField>
                </jr:listContents>
            </jr:list>
        </componentElement>
        <textField isStretchWithOverflow="true" isBlankWhenNull="false">
            <reportElement style="Normal-Text-Small-with-borders" stretchType="RelativeToTallestObject" x="0" y="0" width="20" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" forecolor="#3333FF" uuid="8c9080c7-cb77-430c-be2e-b6252f9b8d8e"/>
            <textElement verticalAlignment="Top">
                <font size="9"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{Workcode}]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
            <reportElement style="Normal-Text-Small-with-borders" stretchType="RelativeToTallestObject" x="450" y="0" width="105" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" forecolor="#3300FF" uuid="ebdd4d26-bc29-4546-a9b5-24f2be132aa8"/>
            <textElement textAlignment="Right">
                <font size="9"/>
                <paragraph lineSpacing="Single"/>
            </textElement>
            <textFieldExpression><![CDATA[($F{WorkcodeAmount}==""||$F{WorkcodeAmount}==null)?0.00:Float.valueOf($F{WorkcodeAmount})/100]]></textFieldExpression>
        </textField>
        <textField isStretchWithOverflow="true" isBlankWhenNull="false">
            <reportElement style="Normal-Text-Small-with-borders" stretchType="RelativeToTallestObject" x="20" y="0" width="130" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" forecolor="#3333FF" uuid="f5fcc495-f401-4498-ac71-7352581cde59"/>
            <textElement verticalAlignment="Top">
                <font size="9"/>
                <paragraph lineSpacing="Single"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{WorkcodeName}]]></textFieldExpression>
        </textField>
    </band>
</detail>

这是我正在测试的XML:

<?xml version="1.0" encoding="UTF-8"?>
<CategoryDetail>
<CategoryCode>1</CategoryCode>
<CategoryName>EXTERNAL CREATIVE</CategoryName>
<CategoryTotalName>TOTAL EXTERNAL CREAT</CategoryTotalName>
<CategoryType>1</CategoryType>
<CategoryStatus>YNNYN</CategoryStatus>
<WorkcodeDetail>
    <WorkcodeCategory>1</WorkcodeCategory>
    <Workcode>1B</Workcode>
    <WorkcodeName>VISUALS</WorkcodeName>
    <WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
    <WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
    <ExtraWorkcodeName>Concept and Development</ExtraWorkcodeName>
    <WorkcodeType>C</WorkcodeType>
    <WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
    <WorkcodeCategory>1</WorkcodeCategory>
    <Workcode>1C</Workcode>
    <WorkcodeName>COPY WRITING</WorkcodeName>
    <WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
    <WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
    <ExtraWorkcodeName>Visualisation/Finished Art/Lasers</ExtraWorkcodeName>
    <WorkcodeType>C</WorkcodeType>
    <WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
    <WorkcodeCategory>1</WorkcodeCategory>
    <Workcode>1E</Workcode>
    <WorkcodeName>PHOTOGRAPHY</WorkcodeName>
    <WorkcodeAmount>500</WorkcodeAmount>
    <WorkcodeCommissionAmount>75</WorkcodeCommissionAmount>
    <WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
    <WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
    <ExtraWorkcodeName>Setting</ExtraWorkcodeName>
    <WorkcodeType>C</WorkcodeType>
    <WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
    <WorkcodeText>Jaspersoft was originally called Panscopic, and was founded by Al Campa, CEO, and Raj Bhargava, VP of Products in 2001. Panscopic raised $23M from Doll Capital, Discovery Ventures, Morgenthaler Ventures, and Partech. In 2004 Panscopic teamed up with</WorkcodeText>
    <WorkcodeText> Teodor Danciu,[7] acquired the intellectual property of JasperReports, and changed the name of the company to Jaspersoft. Brian Gentile became CEO in 2007.&lt;nl&gt;&lt;nl&gt;Jaspersoft provides commercial software around the JasperReports product, and negotiat</WorkcodeText>
    <WorkcodeText>e contracts with software developers that wish to embed the JasperReports engine into a closed source product.&lt;nl&gt;&lt;nl&gt;Jaspersoft's main related product is JasperReports Server, a Java EE web application that provides advanced report server capabiliti</WorkcodeText>
    <WorkcodeText>es such as report scheduling and permissions. It is available under an open source license for use in conjunction with open source infrastructure such as MySQL and JBoss, or a commercial license for enterprise deployments involving commercial databas</WorkcodeText>
    <WorkcodeText>es and application servers.</WorkcodeText>
</WorkcodeDetail>
<WorkcodeDetail>
    <WorkcodeCategory>1</WorkcodeCategory>
    <Workcode>1F</Workcode>
    <WorkcodeName>ILLUSTRATIONS</WorkcodeName>
    <WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
    <WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
    <ExtraWorkcodeName>Photography</ExtraWorkcodeName>
    <WorkcodeType>C</WorkcodeType>
    <WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
    <WorkcodeCategory>1</WorkcodeCategory>
    <Workcode>1G</Workcode>
    <WorkcodeName>MODEL FEES</WorkcodeName>
    <WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
    <WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
    <ExtraWorkcodeName>Models</ExtraWorkcodeName>
    <WorkcodeType>C</WorkcodeType>
    <WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
<WorkcodeDetail>
    <WorkcodeCategory>1</WorkcodeCategory>
    <Workcode>T9</Workcode>
    <WorkcodeName>T3 Overtime Pr.</WorkcodeName>
    <WorkcodeCommissionRate>150000</WorkcodeCommissionRate>
    <WorkcodeFlags>NNNNNNNN</WorkcodeFlags>
    <ExtraWorkcodeName>T3 Overtime Pr.</ExtraWorkcodeName>
    <WorkcodeType>T</WorkcodeType>
    <WorkcodeEstimateCheck>Y</WorkcodeEstimateCheck>
</WorkcodeDetail>
</CategoryDetail>

1 个答案:

答案 0 :(得分:0)

在textFields中尝试将isRemoveLineWhenBlank =“true”设置为false