rsilverns.sympatico.ca Posted October 23, 2006 Share Posted October 23, 2006 I usually divide my report into pages by implementing dummy groups and having the group header contain each "page" of the report (with sub-reports etc. as required). When implmenting a new report I noticed something odd... Consider the following test report that has 2 groups, each with just a header band. Each group has the "isStartNewPage" option set to true. Code:<?xml version="1.0" encoding="UTF-8"?><!-- Created using JasperAssistant (http://www.jasperassistant.com) --><!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"><jasperReport name="Test" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30" isFloatColumnFooter="true"> <property name="ireport.scriptlethandling" value="0"/> <property name="ireport.encoding" value="UTF-8"/> <import value="java.util.*"/> <import value="net.sf.jasperreports.engine.*"/> <import value="net.sf.jasperreports.engine.data.*"/> <style name="Arial" isDefault="true" fontName="Arial" fontSize="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <variable name="Variable_1" class="java.lang.Integer" calculation="Count"> <variableExpression><![CDATA["test"]]></variableExpression> <initialValueExpression><![CDATA[new Integer(0)]]></initialValueExpression> </variable> <group name="Group_1" isStartNewPage="true"> <groupExpression><![CDATA[$V{REPORT_COUNT}]]></groupExpression> <groupHeader> <band height="55"> <staticText> <reportElement key="staticText" mode="Opaque" x="0" y="0" width="555" height="55" forecolor="#FFFFFF" backcolor="#8080FF"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000" rightBorder="None" rightBorderColor="#000000"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="16" isBold="true"/> </textElement> <text><![CDATA[GROUP 1 HEADER BAND]]></text> </staticText> </band> </groupHeader> </group> <group name="Group_2" isStartNewPage="true"> <groupExpression><![CDATA[$V{REPORT_COUNT}]]></groupExpression> <groupHeader> <band height="55"> <staticText> <reportElement key="staticText" mode="Opaque" x="0" y="0" width="555" height="55" forecolor="#FFFFFF" backcolor="#FF00FF"/> <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000" rightBorder="None" rightBorderColor="#000000"/> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="16" isBold="true"/> </textElement> <text><![CDATA[GROUP 2 HEADER BAND]]></text> </staticText> </band> </groupHeader> </group></jasperReport> When I run the report with no extra space except that required for the header text field, I have both group1 header and group2 header showing up on the same page, 1 after the other. I use an empty data source to test, with a size of 5... on each page I have.. ---- Page Start-----[ GROUP 1 HEADER ] [ GROUP 2 HEADER ] (misc. whitespace to fill page) ---- Page End ------Shouldn't the [ GROUP 1 HEADER ] be on 1 page, and then [ GROUP 2 HEADER ] be on next page? If I set the "isStartNewPage" option for group 1 to be false, then what happens is that every time group 2 header is encountered a new page starts. So with an empty datasource of size 5, this looks like...Page 1:[ GROUP 1 HEADER ][ GROUP 2 HEADER ][ GROUP 1 HEADER ] Page 2, 3, 4:[ GROUP 2 HEADER ][ GROUP 1 HEADER ] Page 5:[ GROUP 2 HEADER ] Link to comment Share on other sites More sharing options...
C-Box Posted October 24, 2006 Share Posted October 24, 2006 The groups just break pages if the groupexpression returns something different than the previous groupexpression returned. So I experienenced. That's why I posted a feature request: http://jasperforge.org/sf/go/artf1651?nav=1 So playing around with MinHeightToStartNewPage could help... but this is not a clean solution. So perhaps you could join my feature-request and Teodor has 10 mins to think about??!?! :-) regards from GermanyC-Box Link to comment Share on other sites More sharing options...
rsilverns.sympatico.ca Posted October 24, 2006 Author Share Posted October 24, 2006 Sorry I forgot to mention, my groups all have the expression of $V{REPORT_COUNT}. I even tried making my own report_count type variable, and tacking "-Group2" onto end of group 2's expression in hopes of mixing up group expressions but they all behaved the same. I will go to your feature request and check it out. Thx Cbox,Robin Link to comment Share on other sites More sharing options...
rsilverns.sympatico.ca Posted October 24, 2006 Author Share Posted October 24, 2006 Should this be posted as a bug lucianc/teodord? Post edited by: rsilver@bfm.bm, at: 2006/10/24 11:45 Link to comment Share on other sites More sharing options...
sundevil Posted November 11, 2006 Share Posted November 11, 2006 I have a similar problem with grouping. Hope any of you can help. I had posted this elsewhere too. I have a report that needs to be exported to Excel. Excel has a limit of 65534 rows on a single worksheet. Therefore for handling larger rows say 1 million records, I add a dummy group called Report_page and set the group expression to new Integer(($V{REPORT_COUNT}.intValue()-1)/1000). I use 1000 rows as a test. All the field names(static text) are in the Report_page header band. All the field value(text field) are in the detail. Lets say my dataset has a total of 4000 rows. I would expect the page break to be at 1000 rows but instead the page breaks at 128 rows. I have also set the minHeightToStartNewPage=0. Looks like this is taking precedence. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now