Recently I've come up to some question related to calendar report in iReport. This is the link I referenced to create a calendar: Sample Report to Create a Monthly Calendar
With the above reference, I created a calendar report that can display court attendance record corresponding to different dates:
<?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="CourtCaseSchedule" language="groovy" columnCount="7" pageWidth="2170" pageHeight="500" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="310" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="4bd402ec-2e5b-4f79-bfb6-69da329d8fe7">
<property name="ireport.zoom" value="0.9090909090909121"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<style name="style1">
<conditionalStyle>
<conditionExpression><![CDATA[$V{COLUMN_NUMBER} % 7 == 1]]></conditionExpression>
<style forecolor="#FF3333" backcolor="#FFFFFF">
<pen lineColor="#000000"/>
</style>
</conditionalStyle>
</style>
<style name="table">
<box>
<pen lineWidth="1.0" lineColor="#000000"/>
</box>
</style>
<style name="table_TH" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_CH" mode="Opaque" backcolor="#FFBFBF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="table_TD" mode="Opaque" backcolor="#FFFFFF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<subDataset name="Table Dataset 1" uuid="6d06249f-027b-4ca5-b2af-256229b56b96"/>
<parameter name="REPORT_MONTH" class="java.lang.String"/>
<parameter name="REPORT_YEAR" class="java.lang.String"/>
<parameter name="srCCS_ReportDataSourceDetailsList" class="java.util.List"/>
<parameter name="srCCS_JasperReportDetails" class="java.lang.String"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Reports\\"]]></defaultValueExpression>
</parameter>
<field name="rCCSDayofWeek" class="java.lang.String"/>
<field name="rCCSDate" class="java.lang.String"/>
<variable name="SUBREPORT_INDEX" class="java.lang.Integer" incrementType="Column">
<variableExpression><![CDATA[$F{rCCSDate}]]></variableExpression>
<initialValueExpression><![CDATA[1]]></initialValueExpression>
</variable>
<title>
<band height="75" splitType="Stretch">
<staticText>
<reportElement mode="Opaque" x="0" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#FF3333" uuid="f86c7aa5-b2fa-4668-aaa4-3f3660d37655"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Sunday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="310" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="fc91553f-de51-43f6-8cfa-fcf5d5dbbd2c"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Monday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="620" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="487a8ddb-6029-4c65-8a40-afabdb55d613"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Tuesday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="930" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="c9a33cdb-66de-47a7-a350-d2a7672ec3ce"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Wednesday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1240" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="0555ba56-fd4c-4f02-b0a2-c51945547af4"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Thursday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1550" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="62afe59e-0dda-4b68-89d0-5e3bc6dbf1f8"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Friday]]></text>
</staticText>
<staticText>
<reportElement mode="Opaque" x="1860" y="43" width="310" height="32" forecolor="#FFFFFF" backcolor="#666666" uuid="56f14a13-3fe0-41c2-827b-8cbce1234467"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="22" isBold="true"/>
</textElement>
<text><![CDATA[Saturday]]></text>
</staticText>
<textField>
<reportElement x="0" y="0" width="2170" height="43" uuid="2772960e-b50a-4f5f-a80a-56aa8e28891a"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="32" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Court Case Schedule of " + $P{REPORT_MONTH} + " " + $P{REPORT_YEAR}]]></textFieldExpression>
</textField>
</band>
</title>
<detail>
<band height="300" splitType="Stretch">
<frame>
<reportElement stretchType="RelativeToBandHeight" x="0" y="0" width="310" height="300" uuid="cd88766b-0047-4150-b29c-2e7227fbb00c"/>
<textField>
<reportElement style="style1" positionType="Float" mode="Transparent" x="0" y="0" width="68" height="58" uuid="293e7d8e-d54f-4776-9311-7d9f0270d573">
<printWhenExpression><![CDATA[$F{rCCSDayofWeek}.isEmpty() || $F{rCCSDayofWeek}.equals(java.lang.Integer.toString($V{COLUMN_NUMBER}))]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="28" isBold="true"/>
<paragraph leftIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{rCCSDate}]]></textFieldExpression>
</textField>
<subreport>
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="58" width="310" height="242" uuid="f8fcd85a-d8cf-4b88-b563-652f6d13351d"/>
<dataSourceExpression><![CDATA[$P{srCCS_ReportDataSourceDetailsList}.get($V{REPORT_COUNT}-1)]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "CourtCaseSchedule_SubReport.jasper"]]></subreportExpression>
</subreport>
</frame>
</band>
</detail>
</jasperReport>
This report simply generates a monthly calendar with a sub-report in each cell, where the sub-report displays the court attendance information according to each date.
The problem now is, with the fixed page height of the main report, when there's too many rows inside the sub-report and its heights overflows the page height of the main report, it automatically switches to the next column of the report. As a result the report will become malformed. I've looked for various solution for the overflow issue but none of them worked. Can someone enlighten me to have a workaround for this?
Here are some attributes that are available in Jasper that I've tried:
- Position Type: Float
- Report Split Type: Stretch
- Include
rowandcolumnattribute inside the report element fromnet.sf.jasperreports.export.xls.auto.fit - Setting detail band height during runtime