Jump to content
Changes to the Jaspersoft community edition download ×

Last record


doublep

Recommended Posts

Is it possible to find if the given record is the last one? I could probably compare $V{RECORD_COUNT} with something, but with what? Given that there is <sortField>, JR can re-sort input data on the fly, so it knows total number of records. But how do I find it?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Here is a simple JRXML that I created following your suggestion. As I understand it, at least. It is supposed to create output with value of "person" field per line, last line should also contain its own number. However, I get no numbers at all.

 

<?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="test" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">

<field name="person" class="java.lang.String"/>

<variable name="numRecords" class="java.lang.Integer" incrementType="Report">

<variableExpression><![CDATA[$V{REPORT_COUNT}]]></variableExpression>

</variable>

<detail>

<band height="15" splitType="Stretch">

<textField>

<reportElement x="0" y="0" width="200" height="15"/>

<textFieldExpression><![CDATA[$F{person}]]></textFieldExpression>

</textField>

<textField>

<reportElement x="300" y="0" width="200" height="15">

<printWhenExpression><![CDATA[$V{REPORT_COUNT} + 1 == $V{numRecords}]]></printWhenExpression>

</reportElement>

<textFieldExpression><![CDATA[string.valueOf ($V{REPORT_COUNT})]]></textFieldExpression>

</textField>

</band>

</detail>

</jasperReport>

 

Link to comment
Share on other sites

The evalaution time for $V{REPORT_COUNT} can only be used to display its content in the report. If used for comparison, $V{REPORT_COUNT} contains the value reflecting number of record being fecthed at that particular time when comparison is made. My suggestion is to get the row count total in your query and use it to compare with $V{REPORT_COUNT} when report is processed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...