Jump to content
We've recently updated our Privacy Statement, available here ×

First Page of Subreport blank


howudodat

Recommended Posts

I have a simple report with an embedded sub-report.  The outer loop produces 5 entries and the sub report produces 5 entries that are split across 2 pages.  This should produce a 10 page report.  However I am getting 11 pages with the first page being just the outer report, with the detail blank.  Any ideas?

Below is a simple Java function and the two reports

Peter

Code:
Java:	protected void tryReport() {		try {			List<HashMap<String, Object>> clientlist = new ArrayList<HashMap<String, Object>>();			for (int x = 0; x<5; x++) {				HashMap<String, Object>row = new HashMap<String, Object>();				row.put("Client", "Client Name"+x);				row.put("rep", "Peter");				row.put("assistant", "Helper");								// insert sub report here				List<HashMap<String, Object>>homeslist = new ArrayList<HashMap<String, Object>>();				for (int y = 0; y<5; y++) {					HashMap<String, Object>rowHome = new HashMap<String, Object>();					rowHome.put("facility", "facility name"+y);					rowHome.put("website", "its url");					rowHome.put("address", "12345 Main String MyTown, MS  12345");					homeslist.add(rowHome);				}				row.put("subrpt", new JRMapArrayDataSource(homeslist.toArray()));				clientlist.add(row);			}						JRMapArrayDataSource dsClients = new JRMapArrayDataSource(clientlist.toArray()); 			JasperPrint jasperPrint = JasperFillManager.fillReport("reports/client_referral.jasper", new HashMap(), dsClients);			JasperViewer jv = new JasperViewer(jasperPrint);			jv.setVisible(true);					} catch (Exception e) {			e.printStackTrace();			System.exit(1);		}	}client_referral:<?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="DbReportDS" pageWidth="612" pageHeight="791" columnWidth="572" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">	<property name="ireport.zoom" value="1.0"/>	<property name="ireport.x" value="0"/>	<property name="ireport.y" value="0"/>	<field name="Client" class="java.lang.String"/>	<field name="rep" class="java.lang.String"/>	<field name="assistant" class="java.lang.String"/>	<field name="facility" class="java.lang.String"/>	<field name="website" class="java.lang.String"/>	<field name="address" class="java.lang.String"/>	<field name="notes" class="java.lang.String"/>	<field name="subrpt" class="net.sf.jasperreports.engine.data.JRMapArrayDataSource"/>	<pageHeader>		<band height="102">			<textField>				<reportElement x="1" y="35" width="100" height="20"/>				<textElement>					<font size="14" isBold="true"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA[$F{Client}]]></textFieldExpression>			</textField>			<textField>				<reportElement x="45" y="55" width="100" height="20"/>				<textElement verticalAlignment="Bottom">					<font isBold="true"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA[$F{rep}]]></textFieldExpression>			</textField>			<textField>				<reportElement x="88" y="73" width="100" height="20"/>				<textElement verticalAlignment="Bottom">					<font isBold="true"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA[$F{assistant}]]></textFieldExpression>			</textField>			<staticText>				<reportElement x="16" y="59" width="26" height="16"/>				<textElement verticalAlignment="Bottom">					<font isBold="true"/>				</textElement>				<text><![CDATA[Rep:]]></text>			</staticText>			<staticText>				<reportElement x="34" y="77" width="52" height="16"/>				<textElement verticalAlignment="Bottom">					<font isBold="true"/>				</textElement>				<text><![CDATA[Assistant:]]></text>			</staticText>		</band>	</pageHeader>	<detail>		<band height="172" splitType="Prevent">			<subreport>				<reportElement positionType="Float" x="1" y="0" width="571" height="169" isPrintWhenDetailOverflows="true"/>				<dataSourceExpression><![CDATA[$F{subrpt}]]></dataSourceExpression>				<subreportExpression class="java.lang.String"><![CDATA["client_referral_s1.jasper"]]></subreportExpression>			</subreport>		</band>	</detail></jasperReport>client_referral_s1:<?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="DbReportDS" pageWidth="612" pageHeight="791" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">	<property name="ireport.zoom" value="1.0"/>	<property name="ireport.x" value="0"/>	<property name="ireport.y" value="0"/>	<field name="Client" class="java.lang.String"/>	<field name="rep" class="java.lang.String"/>	<field name="assistant" class="java.lang.String"/>	<field name="facility" class="java.lang.String"/>	<field name="website" class="java.lang.String"/>	<field name="address" class="java.lang.String"/>	<field name="notes" class="java.lang.String"/>	<field name="subrpt" class="net.sf.jasperreports.engine.data.JRMapArrayDataSource"/>	<detail>		<band height="164" splitType="Prevent">			<textField>				<reportElement x="1" y="15" width="234" height="20"/>				<textElement verticalAlignment="Bottom">					<font size="14" isBold="true"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA[$F{facility}]]></textFieldExpression>			</textField>			<textField>				<reportElement x="470" y="15" width="100" height="20"/>				<textElement verticalAlignment="Bottom"/>				<textFieldExpression class="java.lang.String"><![CDATA[$F{website}]]></textFieldExpression>			</textField>			<textField>				<reportElement x="16" y="35" width="362" height="15"/>				<textElement verticalAlignment="Bottom">					<font isBold="true"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression>			</textField>			<textField>				<reportElement x="173" y="61" width="397" height="93"/>				<textElement/>				<textFieldExpression class="java.lang.String"><![CDATA[$F{notes}]]></textFieldExpression>			</textField>		</band>	</detail></jasperReport>
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Remove Page Break in the Subreport, if any.

I was facing the same issues while using nested subreport. I was using Page Break in the Title Section which seemed to be parsed before the other contents of the report. Although there was content before and after the page break, all the contents were coming in the next page.

Try removing the page break and execute the report.

Link to comment
Share on other sites

Check if in the Subreport Property- Title on New Page is Checked. This will lead to the the title getting displayed as blank page even if the content might not be there. If this is not the issue, can you paste the JRXMLs here.

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...