【问题标题】:display column header in jasper reports在 jasper 报告中显示列标题
【发布时间】:2016-12-02 06:13:03
【问题描述】:

尝试创建jasper报告,导出到xls或csv时可以看到数据。但是缺少列标题,不确定它有什么问题,以下是我的报告。提前致谢。

<?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="scireport" language="groovy" printOrder="Horizontal" pageWidth="5000" pageHeight="792" whenNoDataType="AllSectionsNoDetail" columnWidth="4960" 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"/>
    <queryString language="SQL">
        <![CDATA[select PICKUP_DATE from SCI_PLDDATA_VIEW order by EVENT_TIMESTAMP DESC]]>
    </queryString>
    <field name="PICKUP_DATE" class="java.sql.Timestamp">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>
    <group name="stopid">
        <groupHeader>
            <band height="50"/>
        </groupHeader>
    </group>
    <columnHeader>
        <band height="44" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="900" height="20"/>
                <textElement>
                    <font size="14" isBold="true"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$R{jasper.PICKUP_DATE}]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="34" splitType="Stretch">
            <textField isStretchWithOverflow="true" pattern="MM-dd-yyyy HH:mm" isBlankWhenNull="true">
                <reportElement x="0" y="0" width="900" height="20"/>
                <textElement/>
                <textFieldExpression class="java.sql.Timestamp"><![CDATA[$F{PICKUP_DATE}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

【问题讨论】:

  • 你能提供你的数据库吗?
  • @user1791574 使用 oracle
  • 看起来不错。我已经用我的数据运行了它。我没有任何问题。
  • 感谢您的宝贵时间!我可能错过了有关 jasper 报告的任何配置。
  • $R{jasper.PICKUP_DATE} ,你想用这个来描述什么。我之前在 iReport 中不使用“R”数据类型。

标签: jasper-reports


【解决方案1】:

您正在从数据库中获取数据,您的值将出现在字段中。您应该在列标题中使用$F{} 而不是$R{}。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多