代码之家  ›  专栏  ›  技术社区  ›  DonX

在Jasper报告详细信息中打印序列号

  •  2
  • DonX  · 技术社区  · 15 年前

    我已经创建了一个Jasper报告。在那个报告的细节部分,我有“序列号”栏。该列希望是自动递增的,并用“1”进行统计。我正在使用 hibernate 用于查询。 示例代码为:

    <detail>
        <band height="17" splitType="Stretch">
            <textField isBlankWhenNull="true">
                <reportElement x="12" y="0" width="27" height="15"/>
                <textElement/>
                <textFieldExpression class="java.lang.Integer"><![CDATA[serialNumber]]>
                </textFieldExpression>
            </textField>
            <textField>
                <reportElement x="51" y="0" width="37" height="15"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{date}]]>
                </textFieldExpression>
            </textField>
            <textField>
                <reportElement x="138" y="0" width="75" height="15"/>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{time}]]>
                </textFieldExpression>
            </textField>
        </band>
    </detail>
    

    有人能帮我在Jasper报告中打印序列号吗?

    4 回复  |  直到 9 年前
        1
  •  5
  •   DonX    15 年前

    使用变量,我们可以做到这一点。

    样例代码:

     <variable name="seraialNumber" class="java.lang.Integer" resetType="None" 
    calculation="Count"/>
    

    根据需要,我们必须更改表达式

        2
  •  1
  •   Aaron Digulla    15 年前

    您必须将列绑定到返回递增数字的bean。

        3
  •  1
  •   Mayur Bhokase    10 年前

    对于这个内置变量$v_report_count_的问题,您可以使用其他解决方案。

    此变量将以整数格式返回行计数。

    示例表达式:

    <textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>.
    
        4
  •  0
  •   FIFA oneterahertz    9 年前
    <variable name="serial number" class="java.lang.Integer" resetType="Column" calculation="Count">
            <variableExpression><![CDATA[0]]></variableExpression>
        </variable>
    

    我会展示一个图像以便更好地理解 enter image description here

    推荐文章