I have 9 text fields, I want to stretch all these text fields with data overflow. In my case, for all text fields I set position type to 'float' and I checked 'stretch with overflow'. And I put each row in Frame.
But I got a bad design, so I want to align the text fields relating to values 2 and 3 with the others texts fields.
Example : enter link description here
Thanks in advance.
Best Regards.
You cannot have an option to adjust the position of the text based on the fields in Left and Right. Also from your design, I can imagine that the Left and Right text boxes are inside List component or Table component.
Position of text boxes inside List or Table component cannot be adjusted based on the position of text boxes which are not inside the table or list component.
Posting a proper design or sample JRXML might be helpful to solve your problem.
Problem is solved :
I created Frame and group selected elements for each row.
<frame>
<reportElement uuid="70cb42df-4e8f-4cbc-8d8f-f86a4aef9e3d" positionType="Float" x="119" y="233" width="332" height="20" isPrintWhenDetailOverflows="true"/>
</frame>
<frame>
<reportElement uuid="4ca6a014-3eca-4c16-ae4e-079216b1e010" positionType="Float" x="119" y="253" width="332" height="20" isPrintWhenDetailOverflows="true"/>
</frame>
<elementGroup>
<textField isStretchWithOverflow="true">
<reportElement uuid="b6102d47-3114-4673-a241-4dddb0e556bd" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="133" y="213" width="100" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["1"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="c22b46b5-e528-4bb5-ad1c-a5fca06faf38" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="383" y="213" width="55" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["value 1"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="66833d4b-1a6b-4398-9431-ed3ef80ef7dc" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="233" y="213" width="150" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["azertyuiop aaaaaaaaaaaaaaazeeeeeeerrrrrrrrrrrrtttttttttttttttttttttpmmmmmmmmmmmmmlk"]]></textFieldExpression>
</textField>
</elementGroup>
<frame>
<reportElement uuid="bc738f1d-150b-4959-9bc5-6a00b7112969" positionType="Float" x="119" y="213" width="332" height="20" isPrintWhenDetailOverflows="true"/>
</frame>
<elementGroup>
<textField isStretchWithOverflow="true">
<reportElement uuid="78d019fd-5e89-47f1-a895-9a4f0f754000" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="133" y="233" width="100" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["2"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="5935ad61-77ec-4b05-84bf-6f72d3dcd0bd" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="233" y="233" width="150" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["DP-GI"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="83d4865c-f1af-4361-b6fd-9575a9835c7f" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="383" y="233" width="55" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["value 2"]]></textFieldExpression>
</textField>
</elementGroup>
<elementGroup>
<textField isStretchWithOverflow="true">
<reportElement uuid="1a2694c6-974b-493a-b0a6-09b2be10f63a" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="133" y="253" width="100" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["3"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="450e7cce-5a49-4bbc-b502-d86352c7c873" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="233" y="253" width="150" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["AS-GE"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true">
<reportElement uuid="d8e7b402-0081-46ca-bd1c-2c3ae992b957" style="table" positionType="Float" stretchType="RelativeToTallestObject" x="383" y="253" width="55" height="20"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA["value 3"]]></textFieldExpression>
</textField>
</elementGroup>
Here is the result : enter link description here
Best Regards.
Related
I have a Jasper report that is iterating over a list of data returned by a query and displaying the data in tabular format. Depending on the number of table rows the contents of the table might be split across two pages.
Is there a way to prevent this data splitting and cause the entire table to appear on the next page if it doesn't all fit on the current page?
The detail band of my report is as follows:
<detail>
<band height="100" splitType="Prevent">
<componentElement>
<reportElement x="0" y="0" width="800" height="20" isPrintWhenDetailOverflows="true" uuid="3e389075-14ca-4f57-9d02-175fbc34a639"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="output" uuid="acf7113d-1f5a-4acc-ad2c-70efb491bb4f">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{output})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="60" width="800">
<textField>
<reportElement isPrintRepeatedValues="false" x="0" y="20" width="555" height="20" uuid="156e4ef8-b8d9-4dc4-8a50-4f27e0f36a83"/>
<textFieldExpression><![CDATA[$F{reference}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="0" y="40" width="200" height="20" uuid="3e389075-14ca-4f57-9d02-175fbc34a639"/>
<jr:list printOrder="Vertical">
<datasetRun subDataset="unitDetails" uuid="acf7113d-1f5a-4acc-ad2c-70efb491bb4f">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{units})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="40" width="800">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="ead7d8ba-12e2-4a0e-af92-66a50b34148f"/>
<textFieldExpression><![CDATA[$F{businessUnit}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="0" y="20" width="800" height="20" uuid="85e29233-08b3-4717-b260-82c9e4a003c5"/>
<jr:table>
<datasetRun subDataset="codeDetails" uuid="1f5dfa57-f961-4574-b663-8637b2aa6f6e">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{codes})]]></dataSourceExpression>
</datasetRun>
<jr:column width="100" uuid="f832562c-1459-44a4-89df-fe5feadfe7ee">
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="e2ce6b92-bf8a-45f8-936a-af99b2ced4e7"/>
<textElement textAlignment="Left"/>
<textFieldExpression><![CDATA[$F{code}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="150" uuid="b8c51d7d-f4d2-47c9-90a8-2449dff2a9f9">
<jr:columnHeader height="20">
<staticText>
<reportElement x="0" y="0" width="150" height="20" uuid="2fc57842-d68d-4398-a0df-4eddd74316fd"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Total]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="150" height="20" uuid="b2953321-ce5d-4e5f-94e3-8b48b49bbf90"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="150" uuid="f8e255a7-951d-43ad-962b-f4ee32efaa80">
<jr:columnHeader height="20">
<staticText>
<reportElement x="0" y="0" width="150" height="20" uuid="69deede1-0fbc-4fd0-b430-4f0f3cacdc4f"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Approved]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="150" height="20" uuid="200263e0-f9fb-4626-8cee-3eb838d51add"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{approved}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="150" uuid="b4d8feb1-4134-4302-bad1-902685238d3e">
<jr:columnHeader height="20">
<staticText>
<reportElement x="0" y="0" width="150" height="20" uuid="096581a7-beec-43bc-a17e-ce96c4384838"/>
<textElement textAlignment="Right"/>
<text><![CDATA[Rejected]]></text>
</staticText>
</jr:columnHeader>
<jr:detailCell height="20">
<textField>
<reportElement x="0" y="0" width="150" height="20" uuid="3c5d019f-c4af-479b-b180-d52a6606d4e0"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{rejected}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</jr:listContents>
</jr:list>
</componentElement>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
The report output looks like the following where the bottom of the page has the table headings but not the contents because the contents don't fit.
I'm defining a report for invoices, an invoice may have n items (rows) in the detail. I defined a dataset in order to display the items without the need of a subreport. Here my Detail-band:
<detail>
<band height="275" splitType="Stretch">
<rectangle>
<reportElement x="0" y="0" width="60" height="16" uuid="590f4cac-fba0-4e0b-aa74-db059a817946"/>
</rectangle>
<rectangle>
<reportElement x="60" y="0" width="140" height="16" uuid="1cc31301-e884-4648-952d-a68bcaa12b23"/>
</rectangle>
<rectangle>
<reportElement x="200" y="0" width="31" height="16" uuid="ac690ad3-a913-454f-80d0-574505609db1"/>
</rectangle>
<rectangle>
<reportElement x="231" y="0" width="100" height="16" uuid="6d623fd0-df6f-4ffd-b92b-8f18e0d2d5b2"/>
</rectangle>
<rectangle>
<reportElement x="331" y="0" width="37" height="16" uuid="afef801a-3280-4810-8d85-c1f591d2b75b"/>
</rectangle>
<staticText>
<reportElement x="3" y="2" width="44" height="11" uuid="f525bb2b-106a-44a3-9fb0-817f1eeb8260"/>
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[Artikel]]></text>
</staticText>
<staticText>
<reportElement x="63" y="2" width="126" height="11" uuid="0f97aa9e-cb83-4a95-92fc-fdc01e1506f1"/>
<textElement>
<font size="6"/>
</textElement>
<text><![CDATA[Beschreibung]]></text>
</staticText>
<staticText>
<reportElement x="207" y="2" width="22" height="11" uuid="6234d14c-abe2-482e-b6bb-f1c65dc19005"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[Menge]]></text>
</staticText>
<staticText>
<reportElement x="237" y="2" width="92" height="11" uuid="2bd9712e-b8be-4b90-823d-a530f6c7dcba"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[Einheitspreis]]></text>
</staticText>
<staticText>
<reportElement x="340" y="2" width="25" height="11" uuid="dbf02042-62f2-4b70-9b8b-fae588cb8055"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[Rabatt]]></text>
</staticText>
<rectangle>
<reportElement x="368" y="0" width="70" height="16" uuid="54f1f443-d742-4287-8ae6-d06b04682bf4"/>
</rectangle>
<rectangle>
<reportElement x="437" y="0" width="34" height="16" uuid="f23aa7d5-3eb9-478a-a799-a8acfe96d7af"/>
</rectangle>
<rectangle>
<reportElement x="471" y="0" width="84" height="16" uuid="7b4a3a55-b161-44c7-8512-33a127d68ba3"/>
</rectangle>
<staticText>
<reportElement x="381" y="2" width="54" height="11" uuid="e12d9869-3dcd-4b81-89f8-b3a3c6b2e28c"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[MwSt. Grundlage]]></text>
</staticText>
<staticText>
<reportElement x="441" y="2" width="28" height="11" uuid="fb7f8a0e-1632-454f-9742-5179831c8dc4"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[MwSt.]]></text>
</staticText>
<staticText>
<reportElement x="505" y="2" width="47" height="11" uuid="da9a079f-dc7e-4fef-9f31-eabd65340967"/>
<textElement textAlignment="Right">
<font size="6"/>
</textElement>
<text><![CDATA[MwSt. Betrag]]></text>
</staticText>
<rectangle>
<reportElement x="0" y="16" width="60" height="248" uuid="cd7f5e9a-aeae-425c-8783-22084707b432"/>
</rectangle>
<rectangle>
<reportElement x="60" y="16" width="140" height="248" uuid="01ee9155-aed8-4a55-8160-5f73ac6b1085"/>
</rectangle>
<rectangle>
<reportElement x="200" y="16" width="31" height="248" uuid="66698906-69ee-4fdc-8a04-ce14372bd065"/>
</rectangle>
<rectangle>
<reportElement x="231" y="16" width="100" height="248" uuid="0c260fbe-b300-4962-ad7b-ff7666fa2baa"/>
</rectangle>
<rectangle>
<reportElement x="331" y="16" width="37" height="248" uuid="1902828b-f84c-440c-8e3f-24cdffea33ec"/>
</rectangle>
<rectangle>
<reportElement x="368" y="16" width="69" height="248" uuid="880c1b82-4316-493a-b5b3-c4342bbb74c9"/>
</rectangle>
<rectangle>
<reportElement x="437" y="16" width="34" height="248" uuid="ee1c4e69-b69e-4cc8-9b83-24e9867012de"/>
</rectangle>
<rectangle>
<reportElement x="471" y="16" width="84" height="248" uuid="eade602d-0afa-4a6e-a3aa-5de350dc2ee5"/>
</rectangle>
<componentElement>
<reportElement x="0" y="16" width="555" height="17" uuid="be7e1e99-0990-4f3d-beaf-b304c08be036"/>
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
<datasetRun subDataset="items" uuid="ab906203-20bb-4347-806b-ef000f212bf9">
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{righeDocumento})]]></dataSourceExpression>
</datasetRun>
<jr:listContents height="17" width="555">
<textField>
<reportElement x="3" y="2" width="56" height="14" uuid="448ef958-9459-4ab1-8896-f5b65dd7a552"/>
<textFieldExpression><![CDATA[$F{articolo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="63" y="2" width="136" height="14" uuid="24634427-d38f-4679-8996-a96d5051774b"/>
<textFieldExpression><![CDATA[$F{descrizione}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="236" y="2" width="92" height="14" uuid="20bda0b8-a3c0-47e7-bdff-555c481a894d"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[new DecimalFormat("0.00 €").format($F{prezzo})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="207" y="2" width="21" height="14" uuid="61766ba4-57d0-4509-ac41-ffd7bb4e12ef"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{quantita}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="338" y="2" width="27" height="14" uuid="535705c6-d0b6-401d-b767-efafb3ba42f7"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{sconto} == null ? "" : $F{sconto}+" %"]]></textFieldExpression>
</textField>
<textField>
<reportElement x="439" y="2" width="28" height="14" uuid="0dc5fa14-efac-4c5b-898a-9a9152e588f7"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[$F{aliquota}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="375" y="2" width="59" height="14" uuid="2772b49b-5355-463d-bebf-856537a416a3"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[new DecimalFormat("0.00 €").format($F{costo})]]></textFieldExpression>
</textField>
<textField>
<reportElement x="482" y="2" width="70" height="14" uuid="0259a153-a0c2-4589-b296-fdca4ceeed2b"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA[new DecimalFormat("0.00 €").format($F{iva})]]></textFieldExpression>
</textField>
</jr:listContents>
</jr:list>
</componentElement>
</band>
</detail>
The result is to see in the following pictures:
Example with many rows:
Example with two rows:
The problem is that when I have more rows it includes a second page (not shown here in my question) with header and footer, the detail is empty. The rest as we can see from the pics is OK.
Why? How do I fix it?
You have chosen a strange way to create this report, the normal way would be to make the detail band represent 1 article line in your invoice (hence detail band would have the height of 14)
Then if you need to draw lines to the bottom of the page you can always use the background band.
What is happening now?, probably the list overflows in your detail band that also have empty space under it, it can not create another one on same page and move the space to next page.
Solution Use the normal way of jasper report, datasource containing your lines, header in columnHeader band, fields in detail band (height 14) and your vertical lines in
the background band, also exports as to excel etc will be much cleaner.
If you like to keep your list, move all the rectangles to the
background band and reduce height of detail band to remaining
components (header + list height)
So I'm editing a old Jasper document we have in our system. The document presents a packing slip based on a XML file.
Now we would like to do the following:
If there is more than 1 article line with the same article we would like to add those up / combine them into one line.
I'm not very familiar with iReport and I only made some small field linking changes.
When I look at the Xml of the document I see that you can use expressions on textfields that hold some code. I think I would need to write some code for the group representing the article lines right?
Below is the xml part of the article line:
<detail>
<band height="38" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-19_1" style="column_field_small" x="228" y="2" width="264" height="12" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{articleDescription}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-20_2" style="column_field_small" x="5" y="2" width="222" height="12" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{articleCode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-31_5" style="sub_column_header_small" x="229" y="14" width="39" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Quantity}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-32_6" style="sub_column_header_small" x="272" y="14" width="24" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Pack}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-33_7" style="sub_column_header_small" x="415" y="14" width="52" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Grossweight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-34_8" style="sub_column_header_small" x="469" y="14" width="61" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.Nettweight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement key="textField-21_3" style="sub_column_field_small" x="490" y="26" width="40" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{finalNetWeight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="#,##0.00" isBlankWhenNull="true">
<reportElement key="textField-22_4" style="sub_column_field_small" x="427" y="26" width="40" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{finalGrossWeight}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-23_5" style="sub_column_field_small" x="272" y="26" width="24" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{finalPackageCode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" pattern="###0" isBlankWhenNull="true">
<reportElement key="textField-24_6" style="sub_column_field_small" x="228" y="26" width="40" height="12"/>
<textElement textAlignment="Right"/>
<textFieldExpression class="java.lang.Double"><![CDATA[$F{finalQuantity}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="textField-23_5" style="sub_column_field_small" x="300" y="26" width="80" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[( $F{serialCode} != null && $F{serialCode}.length() > 0 ? $F{serialCode} :
( $F{customersPalletCode} != null && $F{customersPalletCode}.length() > 0 ? $F{customersPalletCode} :
( $F{lotCode} != null && $F{lotCode}.length() > 0 ? $F{lotCode} : "" )) )]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-32_6" style="sub_column_header_small" x="300" y="14" width="80" height="12">
<printWhenExpression><![CDATA[new Boolean(1==2)]]></printWhenExpression>
</reportElement>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$R{CWjp.SerPltLotCode}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="staticText-32_6" style="sub_column_header_small" x="380" y="26" width="43" height="12"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["(" + ( $F{serialCode} != null && $F{serialCode}.length() > 0 ? $R{CWjp.Serial} :
( $F{customersPalletCode} != null && $F{customersPalletCode}.length() > 0 ? $R{CWjp.Pallet} :
( $F{lotCode} != null && $F{lotCode}.length() > 0 ? $R{CWjp.Lot1} : "" )) )
+ ")"]]></textFieldExpression>
</textField>
</band>
</detail>
This sounds like a job for Groups. Keep in mind that the data must be sorted before grouping should be applied.
Requirement:
If firstName and lastName is non empty. Show this at x=125, y=3 coordinates.
And show address down to it at x="125" y="26" coordinate. This is working fine.
Problem: If firstName/lastName are empty, Then we need to move the address element up and show it at x=125, y=3 coordinate itself.
This is where I am stuck. Please help me.
Please refer my jrxml file below:
<frame>
<reportElement key="frame-462" positionType="Float" mode="Transparent" x="0" y="50" width="390" height="70"/>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-844" positionType="Float" mode="Transparent" x="125" y="3" width="264" height="23"
isPrintWhenDetailOverflows="true" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[(!$F{firstName}.isEmpty() && !$F{lastName}.isEmpty())]]></printWhenExpression>
</reportElement>
<textElement markup="styled">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression>
<![CDATA[$F{firstName} + "<style pdfFontName='Helvetica-Oblique' size='11'>" + $F{lastName} + "</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-843" mode="Transparent" positionType="Float" x="125" y="26" width="264"
height="42" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
<textElement markup="html">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
<staticText>
<reportElement key="staticText-1249" positionType="Float" x="2" y="2" width="108" height="21"
isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font fontName="Verdana" size="12" isBold="false" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ Address:]]></text>
</staticText>
</frame>
You have already set the isRemoveLineWhenBlank attribute, which will remove the empty space left by the textField. However, JasperReports cannot collapse vertical space unless that space is completely clear. If there is another element occupying the same line (in your case the staticText element), the empty space will be preserved. This is a bit like playing Tetris in reverse; You have to get rid of all of the blocks before the line will disappear.
Putting report elements into frames modifies this behaviour slightly. It is only the width of the parent frame that needs to be clear, instead of the width of the whole report. Therefore, by putting your name and address fields into a separate frame, the space occupied by the name field can collapse despite being aligned horizontally with the static text. I have modified your code snippet to demonstrate this:
<frame>
<reportElement key="frame-462" positionType="Float" mode="Transparent" x="0" y="50" width="390" height="70"/>
<frame>
<reportElement x="126" y="0" width="264" height="70"/>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-844" positionType="Float" mode="Transparent" x="0" y="3" width="264" height="23" isPrintWhenDetailOverflows="true" isRemoveLineWhenBlank="true">
<printWhenExpression><![CDATA[(!$F{firstName}.isEmpty() && !$F{lastName}.isEmpty())]]></printWhenExpression>
</reportElement>
<textElement markup="styled">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{firstName} + "<style pdfFontName='Helvetica-Oblique' size='11'>" + $F{lastName} + "</style>"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now">
<reportElement key="textField-843" mode="Transparent" positionType="Float" x="0" y="26" width="264" height="42" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
<textElement markup="html">
<font fontName="Verdana" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{address}]]></textFieldExpression>
</textField>
</frame>
<staticText>
<reportElement key="staticText-1249" positionType="Float" x="2" y="2" width="108" height="21" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font fontName="Verdana" size="12" isBold="false" pdfFontName="Helvetica-Bold"/>
</textElement>
<text><![CDATA[ Address:]]></text>
</staticText>
</frame>
My question is that how I can set colspan value for a table footer column in iReport, in jrxml file.
I have to use iReport to create easily my PDF design. I send fields and parameters values from PHP via Tomcat. I don't use Java for create a dynamic jasper report.
That means I have to resolve my problem from jrxml.
Is it possible to make it?
You can't do a colspan as such but you can group the table columns in iReport (select more than 1 column in the table footer). Then remove the cells of the individual columns in the footer and add a cell for the "Group Header" in the footer.
All pure iReport/JRXML.
Detail part of xml:
<detail>
<band height="43" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="344" height="20"/>
<box>
<bottomPen lineWidth="0.5"/>
</box>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{data_title}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement key="table" x="0" y="20" width="802" height="20"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="details">
<datasetParameter name="credit">
<datasetParameterExpression><![CDATA[$F{credit}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="debit_gross_sum">
<datasetParameterExpression><![CDATA[$F{debit_gross_sum}]]></datasetParameterExpression>
</datasetParameter>
<datasetParameter name="debit_net_sum">
<datasetParameterExpression><![CDATA[$F{debit_net_sum}]]></datasetParameterExpression>
</datasetParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{details})]]></dataSourceExpression>
</datasetRun>
<jr:column width="12">
<jr:tableFooter height="15" rowSpan="1"/>
<jr:detailCell height="20" rowSpan="1"/>
</jr:column>
<jr:column width="48">
<jr:tableFooter height="15" rowSpan="1"/>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="48" height="20"/>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{time}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="106">
<jr:tableFooter height="15" rowSpan="1"/>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="106" height="20"/>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{description}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="130">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="130" height="15"/>
<box>
<bottomPen lineWidth="0.5"/>
</box>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="130" height="20"/>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{guest_name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="48">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="48" height="15"/>
<box>
<bottomPen lineWidth="0.5"/>
</box>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="48" height="20"/>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{room}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="79">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="79" height="15"/>
<box>
<bottomPen lineWidth="0.5"/>
</box>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="79" height="20"/>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{cachier_user}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="77">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="77" height="15"/>
<box>
<bottomPen lineWidth="0.5"/>
</box>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="77" height="20"/>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{source_room}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="126">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="126" height="15"/>
<box>
<bottomPen lineWidth="0.5"/>
</box>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[""]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="126" height="20"/>
<textElement>
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{source_guest_name}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="15"/>
<box rightPadding="0">
<topPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Right">
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{debit_gross_sum}]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="20"/>
<textElement textAlignment="Right">
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{debit_gross}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="70">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="15"/>
<box rightPadding="0">
<topPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Right">
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{debit_net_sum}]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="70" height="20"/>
<textElement textAlignment="Right">
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{debit_net}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="37">
<jr:tableFooter height="15" rowSpan="1">
<textField isBlankWhenNull="true">
<reportElement x="0" y="0" width="37" height="15"/>
<box>
<topPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Right" verticalAlignment="Top">
<font pdfEncoding="Cp1250"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{credit}]]></textFieldExpression>
</textField>
</jr:tableFooter>
<jr:detailCell height="20" rowSpan="1"/>
</jr:column>
</jr:table>
</componentElement>
</band>
</detail>
I would like to close up from tableFotter 3. cell 4 cells.
Thank you Alex K!