How we can show the current page number in jasper sub report ? i have done for only first page with variable like this $V{PAGE_NUMBER} and "("+$V{PAGE_COUNT}+")" but how we can show in all sub reports ?
you have to use page footer band for that,
set the $V{PAGE_NUMBER}'s print when expression to "REPORT" when you have to display total pages and,
$V{PAGE_NUMBER}'s print when expression to "NOW" when you have to display current page number.
TRY This
<pageFooter>
<band height="22" splitType="Stretch">
<textField pattern="M/d/yy h:mm a">
<reportElement x="580" y="0" width="220" height="20" uuid="941d5c67-e986-4d5b-ba7e-2754f065e008"/>
<box padding="3"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="SansSerif" size="8"/>
</textElement>
<textFieldExpression><![CDATA["Printed on : "+new java.util.Date()]]></textFieldExpression>
</textField>
<textField>
<reportElement x="280" y="1" width="200" height="20" uuid="afe76ecf-00e9-4d52-a00b-44d38dc3aa65"/>
<box padding="3"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA["Page "+$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
Follow the below pattern , it should work.
<jasperReport>
<title>
</title>
<detail>
//Here goes all subreports
</detail>
<pageFooter>
<textField evaluationTime="Report">
<textFieldExpression><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</pageFooter>
</jasperReport>
Related
I am creating an Excel using Jasper Report. I want to create a footer at the end of the columns which has a total. Eg:
Col 1 | Col 2
1.0 1.0
2.0 3.0
Total 3.0 4.0
I have in my XML:
...
<variable name="totalCol1" class="java.math.BigDecimal" calculation="Sum">
<variableExpression><![CDATA[$F{col1}]]></variableExpression>
</variable>
<variable name="totalCol2" class="java.math.BigDecimal" calculation="Sum">
<variableExpression><![CDATA[$F{col2}]]></variableExpression>
</variable>
...
<detail>
<band height="83" splitType="Prevent">
<crosstab isRepeatColumnHeaders="false" columnBreakOffset="0" ignoreWidth="true">
....
....
</crosstab>
</band>
</detail>
<columnFooter>
<band height="210" splitType="Prevent">
<textField>
<reportElement x="2210" y="180" width="100" height="30" uuid="d4580669-65c4-46c2-b7ca-9e10624d9651"/>
<textElement textAlignment="Center">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{lblTotal}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="2310" y="180" width="100" height="30" uuid="1e41e36a-6eca-43d6-8096-edc893686f92"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{totalcol1}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="2410" y="180" width="100" height="30" uuid="ffff6945-f711-44cf-8356-092f3f3da688"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$V{totalCol2}]]></textFieldExpression>
</textField>
</band>
</columnFooter>
Columns 1 and 2 appears. But neither the label for Total nor the sum appears. Can someone help? If you need more info, please comment. Thanks in advance.
I'm currently working in a API that will generate reports (with JasperReports 6.12.2), in this case I have to print a large String in a text field, the problem is that I can't give the appropiate behaviour to this element to adjust the height to the String size.
I've been searching before to ask, and all that I've found was about the property isStretchWithOverflow="true", but isn't working for me because in my version this is deprecated and replaced with textAdjust="StretchHeight" so basically all the results finish with the same, the text is cutted by the text field.
Note: Also I have to say that this necessity of dynamism is because i need to paginate the report.
Element Text Field JRXML code:
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="190" width="555" height="321" isPrintWhenDetailOverflows="true"/>
<textFieldExpression><![CDATA[$P{text}]]></textFieldExpression>
</textField>
Complete Band Detail JRXML code:
<detail>
<band height="802" splitType="Stretch">
<textField>
<reportElement x="0" y="40" width="140" height="20" uuid="8e0ef27f-45c4-45f5-8c36-93e126db95db"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.codigo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="60" width="140" height="20" uuid="6cfe8e0b-0b7d-47f5-be4e-4c94d7f19fac"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.fecha}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="80" width="140" height="20" uuid="c8508fc6-3b17-4bcc-a207-2a9beff32263"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.enviado}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="100" width="140" height="20" uuid="5f7c732e-aeee-4896-bf11-dbd8f2c2b02f"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.asunto}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="120" width="140" height="20" uuid="71f51ac1-63c5-4abb-909a-3f31b14e0e80"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.canal}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="140" width="140" height="20" uuid="00e9ac8d-c331-429d-944a-240e6abf2107"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.nombre}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="160" width="140" height="20" uuid="4b22fdfb-36a3-41da-86d1-a527ca67667d"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.texto}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="40" width="405" height="20" uuid="bc346e06-c225-4451-bde7-67bde39d402e"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{codigo}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="60" width="405" height="20" uuid="1d0ac2a4-fcb9-4ad3-9d9d-db440ae5cfb3"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").format( new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse($P{fAlta}))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="80" width="405" height="20" uuid="d0189a13-4ded-45a1-82ad-5896a50f7fbf"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{mailPara}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="100" width="405" height="20" uuid="b0cfff7f-9230-4351-a59c-bf550fc4f0c2"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{asunto}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="140" width="405" height="20" uuid="15f48c57-404d-47e2-94a9-26da75054aa9"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{operador}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="150" y="120" width="405" height="20" uuid="0926440c-f596-47a4-b7b4-674faa82b407"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<text><![CDATA[Operador ATC]]></text>
</staticText>
<textField>
<reportElement x="0" y="20" width="140" height="20" uuid="664930ad-64a1-44fc-9cdb-4ef34eb7cffa"/>
<textElement>
<font fontName="SansSerif" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{respuesta.cuerpo.idPeticionATC}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="20" width="405" height="20" uuid="d9303c25-1ea8-45ca-b4b7-984a0b95d4ee"/>
<textElement>
<font fontName="SansSerif" size="11"/>
</textElement>
<textFieldExpression><![CDATA[$P{idPeticionATC}]]></textFieldExpression>
</textField>
<textField textAdjust="StretchHeight">
<reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="190" width="555" height="321" isPrintWhenDetailOverflows="true" uuid="0e59dd92-0a62-453a-9167-6a9d5b43ff54"/>
<textFieldExpression><![CDATA[$P{text}]]></textFieldExpression>
</textField>
</band>
After a while trying to solve this issue I've found the problem.
Recently Jasper Reports upgraded the version to v6.11 (Published: 2019-Dec-12), in this version Jaspersoft® Studio changed the property isstretchwithoverflow is replaced by textAdjust, so the problem was related with the version, and I realized that my Jasper reports library was in an older version v6.2, where the propertie textAdjust doesn't even exist.
So if anyone else is having this problem, please, check your library version, if it's under version 6.11 and your editor plugin is version 6.11 or higher, you will not be able to overflow texts and paginate properly.
The property isStretchWithOverflow was replaced in the JasperReports Library 6.10.0 by the textAdjust property. So to achieve the dynamic stretching effect, you need to set textAdjust="StretchHeight".
If you set your compatibility settings in Jaspersoft Studio ("Window > Preferences > Jaspersoft Studio > Compatibility") accordingly, it will automatically change the property to the compatible version, i.e. textAdjust="StretchHeight" will automatically be exchanged for isStretchWithOverflow="true" when you select a version <= JasperReports 6.5.1.
I am running a jasper report on an select query, I am grouping the result by few values and using the same fields in my header
Below is my jasper group expression and header.
<groupExpression><![CDATA[$F{tray_code} + $F{card_id} + $F{card_position}+$F{card_number}+ $F{card_from_date}+ $F{card_to_date} + $F{week_number}+$F{patient_id} + $F{patient_full_name}]]></groupExpression>
<groupHeader>
<band height="15">
<textField isBlankWhenNull="true">
<reportElement x="5" y="0" width="20" height="14" uuid="97fd5e2c-50e4-46e4-9c1b-0453f5cd05b5"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{tray_code}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="26" y="0" width="44" height="14" uuid="d16ea2fb-367a-4b5e-986e-bc19669c3091"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{card_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="95" y="0" width="25" height="14" uuid="b7eb1f75-44d4-467e-8463-29f6f6f4555b"/>
<textElement textAlignment="Center">
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{card_position}]]></textFieldExpression>
</textField>
<textField pattern="">
<reportElement x="120" y="0" width="55" height="14" uuid="10e4bc1b-cfbb-478d-bd10-a6284bd3bac1"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd/MM/yyyy").format(new SimpleDateFormat("yyyy-MM-dd").parse($F{card_from_date}))]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy">
<reportElement x="175" y="0" width="55" height="14" uuid="a7d34de5-c4de-4093-9da7-96119450c3ab"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new SimpleDateFormat("dd/MM/yyyy").format(new SimpleDateFormat("yyyy-MM-dd").parse($F{card_to_date}))]]></textFieldExpression>
</textField>
<textField>
<reportElement x="230" y="0" width="24" height="14" uuid="9cf3bce2-cb70-45e7-8199-0d6c8003ce53"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{week_number}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="270" y="0" width="67" height="14" uuid="d9e50bb7-1616-4d84-b92f-246abd05ae7b"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{patient_id}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="337" y="0" width="250" height="14" uuid="b06f0d0d-739b-4e2a-a2bc-1686c9d5cbfe"/>
<textElement>
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{patient_full_name}]]></textFieldExpression>
</textField>
<line>
<reportElement x="0" y="14" width="752" height="1" uuid="968c2e25-462d-4b0a-90e2-34570db25d0f"/>
<graphicElement>
<pen lineWidth="1.0" lineStyle="Dashed" lineColor="#999999"/>
</graphicElement>
</line>
<textField>
<reportElement x="70" y="0" width="25" height="14" uuid="7f4ba299-706f-4ba6-aafc-ffa47b0e4374"/>
<textElement textAlignment="Center">
<font fontName="DejaVu Sans" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{card_number}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
According to the above group expression, I expect only one header for a group, But I see the group header for the same group is repeated in my output file ! Please let me know what I am doing wrong.
Thanks in Advance.
So there is an issue that happens when you use multiple group headers. The first header behaves like expected ordered by Column Value A only on unique values.
The 2nd header using Column Value B will print on every row despite being non-unique values.
In theory you should be able to use:
1.
ORDER BY ValueA, ValueB
to properly display the report assuming you are using sql, plsql, etc...
However, in my case that did not happen, though for others it seems to work.
2.
Use subreports to attach the minor differences via unique reports.
You create a root report with empty details.
Then you create Unique reports to serve as sub reprots.
Finally, you use the subreport element to link the values into the root report. Though that is a good bit of work and may cause repeat code.
A hacky way I used was:
A mixture of "Print When Expressions" with logical boolean like below
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("QueryA") && $P{P_parameter} == null)
and
$F{QUERY}.equals(Query1) && ($P{P_Typequery}.equalsIgnoreCase("P_QueryA") && $P{P_parameter} != null)
with two group headers and a column header. The column header will not repeat for every row so you assign one of the booleans expressions to it's "print when" so it does not always print. The first group header will not repeat for every row and works. The 2nd group header is used for the times you DO want it to repeat for every unique value since it always prints for every row, and you use the other boolean on it's "print when".
Hope it helps
I am using iReport. I want to know how to make an auto height rectangle?
as per this sample image of detail band. There is two part one is data part on right side which fetch data and show. and left side part is a textarea data which is passed as parameter.
I want to make both rectangle same height. It may possible that left side data height is bigger than right side part and vice versa. So I want to make both rectangle height same all the time.
For achieving this i use following code. where I don't use rectangles but a lines only
<columnHeader>
<line>
<reportElement x="0" y="28" width="555" height="1" uuid="9d2cb019-77f2-47a0-94f7-aa944b5c277e"/>
</line>
</band>
</columnHeader>
<detail>
<band height="13" splitType="Stretch">
<textField>
<reportElement x="472" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
<textElement verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
</textField>
<line>
<reportElement x="471" y="0" width="1" height="13" uuid="434d1954-3286-4539-a3d9-915f28364210"/>
</line>
<line>
<reportElement x="555" y="-1" width="1" height="13" uuid="39dab81d-1bb3-41bd-8fff-9780b7f65672"/>
</line>
<line>
<reportElement x="0" y="-1" width="1" height="13" uuid="8936db56-872f-434d-a39b-298ffdb99e57"/>
</line>
</band>
</detail>
<summary>
<band height="1" splitType="Stretch">
<line>
<reportElement x="0" y="-1" width="555" height="1" uuid="ba7dbcc7-fd20-4ee9-b593-480737f9b88c"/>
</line>
</band>
</summary>
But the issue with this way is corners of rectangle is not properly printed.
My questions are:
1) Is there any better way to do this?
2) how to draw a border of complete detail band?
3) How to do this with rectangle ?
Here is another try with rectangle around detail band but rectangle is repeated to each row.
<detail>
<band height="13" splitType="Stretch">
<rectangle>
<reportElement stretchType="RelativeToTallestObject" x="1" y="0" width="552" height="13" uuid="80b946be-ac5f-495d-a507-fec3e22ea751"/>
</rectangle>
<textField>
<reportElement x="465" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
<textElement textAlignment="Right" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
<textElement verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
</textField>
</band>
</detail>
Hello I think you can find the answer in their documentation in this Link:
https://community.jaspersoft.com/wiki/dynamically-set-table-row-height-data
To sum up here are the options you should enable.
I think you should have one rectangle and place a line in between. Use the property of line, check stretchWithOverflow to true. Simillarly with rectangle.
First select your field and set following properties (third one is most important):
Position type: float
Stretch type: relative to tallest object
Stretch with overflow: true (checked)
I am generating the reports using jasperreport-4.5.0.It is generating the report properly.But if i have huge data in my database then the report vl display in different pages.So my requirement is if my report has 12 pages then i want to display page 1 of 12,page 2 of 12,page 3 of 12....like this in my page header band.How can i do this can any one give an idea regarding this.
You can use the evaluationTime="Report" attribute to achieve this.
Consider the following example, we first print "PAGE" then we print the page number using the default evalutaionTime attribute. This will print the current page number, then we print OF and finally the page number with evaluation time set to "report" which will print the total number of pages.
<band height="20">
<elementGroup>
<textField>
<reportElement positionType="FixRelativeToBottom" x="709" y="0" width="53" height="20"/>
<textElement verticalAlignment="Top">
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA["PAGE"]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="762" y="0" width="23" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField>
<reportElement positionType="FixRelativeToBottom" x="785" y="0" width="29" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA["OF"]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement positionType="FixRelativeToBottom" x="814" y="0" width="26" height="20"/>
<textElement>
<font size="12"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</elementGroup>
</band>