how to make the cell stretch as per the length of the data in the cell (<textField isStretchWithOverflow="true">) [duplicate] - jasper-reports

This question already has answers here:
How to stretch textfield in a JasperReport as per dynamic content?
(8 answers)
Stretch overflow not working in excel jasper report
(3 answers)
Can JasperReports produce Excel file with column widths auto adjusted to contents?
(1 answer)
iReport issue with isStretchWithOverflow
(1 answer)
JasperReport - wrap text to show long text in textfield
(3 answers)
Closed 3 months ago.
enter image description hereenter image description herefor the report, i want the cell to stretch as per the length of the data in the cell
currently my report looks like this
the code:
<jr:column width="100" uuid="a1e76d15-849b-4f0c-a863-05a154d5291c">
<jr:detailCell style="Table_TD" height="15">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="100" height="15" uuid="c86863d7-007b-4a35-b616-01c4aec548dd">
<property name="net.sf.jasperreports.export.xls.auto.fit.row" value="true"/>
<property name="net.sf.jasperreports.export.xls.auto.fit.column" value="true"/>
<property name="net.sf.jasperreports.export.xls.wrap.text" value="false"/>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="10" isBold="false" pdfFontName="DejaVu Sans" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{uom} != null ? $F{uom} : "-"]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
as you can see the uom, the data inside the cell is croped and sticks close to the cell
expected :
cell to stretch as per the length of the data
or
want the data inside the cell to not get cropped
or
any better way to give proper alignment
Note : i tried width= "150" , still the same result

Add:
<paragraph leftIndent="5" rightIndent="5"/> below <font... >
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="DejaVu Sans" size="10" isBold="false" pdfFontName="DejaVu Sans" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
<paragraph leftIndent="5" rightIndent="5"/>
</textElement>
Adding < paragraph leftIndent="5" rightIndent="5"/ > will create indent of 5 on both sides
**For Top and Bottom margin **
Increase cell height:
<jr:column width="100" uuid="a1e76d15-849b-4f0c-a863-05a154d5291c">
<jr:detailCell style="Table_TD" height="15"> as you have already set vertical alignment middle, extra height will be distributed on top and bottom for example you can try setting
<jr:detailCell style="Table_TD" height="25">

Related

how to skip record when condition met in jasper table?

I am creating jasper report. I want to skip that rows when condition met on one variable. what I have done selecting all text boxes in table and in printwhenExprssion written
$F{totalApiReceived} >0
this is not printing that rows but blank row is still showing. I have also checked "Remove line when blank" but still blank row is coming in report. I want to skip that row completely.
My text box is like:
<jr:detailCell style="Table 1_TD" height="15">
<textField isBlankWhenNull="false">
<reportElement x="0" y="0" width="100" height="15" isRemoveLineWhenBlank="true" uuid="f8fbbe37-33e4-48de-a70a-ce4aaca5b8d4">
<printWhenExpression><![CDATA[$F{totalApiReceived}>0]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Center">
<font fontName="Arial" size="8"/>
</textElement>
<textFieldExpression><![CDATA["("+$F{carrierType}+")"+" "+ $F{carrierCode}]]></textFieldExpression>
</textField>
</jr:detailCell>
I got the solution by putting
<filterExpression><![CDATA[$F{totalApiReceived} >0]]></filterExpression>
inside the subset tag.

Jasper: collapse white space when string element is empty [duplicate]

This question already has answers here:
How to get rid of this band line in report
(1 answer)
How to remove frame with empty textFields?
(1 answer)
How to use positionType to pull a component up when the above component is not displayed in jasper?
(1 answer)
Closed 3 years ago.
I need to collapse a field when it's null or empty.
I have this jrxml source code
<textField>
<reportElement x="180" y="0" width="200" height="20" uuid="5d7e1430-4275-4c04-a609-b12adf976cd2"/>
<textElement markup="styled">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{title}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="false">
<reportElement positionType="Float" x="180" y="20" width="200" height="20" isRemoveLineWhenBlank="true" uuid="3e10e11d-131e-4059-b885-0210e651b5bd">
<printWhenExpression><![CDATA[$F{vote} != null && !$F{vote}.equals("")]]></printWhenExpression>
</reportElement>
<textElement>
<paragraph lineSpacing="Proportional"/>
</textElement>
<textFieldExpression><![CDATA["Voto: "+$F{vote}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="180" y="40" width="200" height="30" uuid="2623f12e-a68f-4173-8f64-69a54ce50a0a"/>
<textFieldExpression><![CDATA[$F{organisationName}]]></textFieldExpression>
</textField>
The Field Vote sometimes is empty or null and with $F{vote} != null && !$F{vote}.equals("")] it isn't displayed, but the space remain white and it doesn't disappear.
This is my result
This is what I want
Where am I wrong?

jasper excel report export green mark coming

I am using jasper stuido 6 to generated excel report.
After generating report I am getting green mark on cell wherever is number is coming as shown below image
same green mark is not coming from text value only.
I tried to set the below jasper property
<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
and used below code
<jr:column width="50" uuid="d3d82c7c-1121-474f-b0f3-00e80cda4489">
<jr:detailCell height="20">
<textField>
<reportElement style="WhiteBackColor" x="0" y="0" width="50" height="20" uuid="1b71e76d-8111-43ee-9cfb-9070ffcf1f6d">
<printWhenExpression><![CDATA[$F{zeitQuartal}.matches("-?\\d+(\\.\\d+)?")]]></printWhenExpression>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="Calibri" size="11" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[Double.parseDouble($F{zeitQuartal})]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
Then green mark disapper from the generated excel report
but if any text like come in between number that is disappearing

Jasper Reports does not bold text in a pdf file

Using jasper reports (1.3) together with itext library (1.3.1) to make pdf reports. Font is defined as follows:
<reportFont name="font-normal" isDefault="true" fontName="Code2000" size="9" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="CODE2000.TTF" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
We explicitly set isBold="true", however nothing in the report is bold. The font CODE2000.TTF can be used in MS Word with bold style. We also tried without success setting isBold="true" on the element inside like in:
<textField>
<reportElement positionType="Float" x="0" y="120" width="694" height="14"/>
<textElement>
<font size="9" pdfFontName="CODE2000.ttf" pdfEncoding="Identity-H" isPdfEmbedded="true" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String">
"TITLE:"+str($P{title})
</textFieldExpression>
</textField>
Any help is appreciated.

Serial Number Repeating in Jasper Reports

I have used $V{REPORT_COUNT} TO DISPLAY SERIAL NUMBER OF THE RECORDS.For Each Record that is fetched from the database the serial number is displayed correctly.
However if one record that is printed has data more then it can accommodate on a page, it is displayed on the next page. I am fine with that too, however the serial number is again shown for that page Eg. 3 is the serial number and if 3 could not be accommodated on the same page the record is written in the next page and the order of serial number is 1 2 3 (First Page) 3 4 5 etc(second Page).
I want 3 to be displayed only once in the first page and not in the second page. I have uploaded a image of my layout and I do not want to show the circled part I am Using Ireport to design the page
Text Field Properties
This is for the REPORT_COUNT TEXTFIELD
<reportElement
mode="Opaque"
x="0"
y="0"
width="15"
height="30"
backcolor="#D3D3D3"
key="textField-9"
stretchType="RelativeToBandHeight"
positionType="Float"
isPrintRepeatedValues="false"
isRemoveLineWhenBlank="true"
isPrintWhenDetailOverflows="true"/>
<box topBorder="Thin" topBorderColor="#000000" leftBorder="Thin" leftBorderColor="#000000" rightBorder="Thin" rightBorderColor="#000000" bottomBorder="Thin" bottomBorderColor="#000000"/>
<textElement textAlignment="Center" verticalAlignment="Top">
<font fontName="Times New Roman" pdfFontName="Times-Bold" size="10" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{REPORT_COUNT}]]></textFieldExpression>
</textField>
This properties for the right hand side text box which displays data:
<textField isStretchWithOverflow="true" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >
<reportElement
mode="Opaque"
x="12"
y="0"
width="523"
height="13"
forecolor="#000000"
backcolor="#D3D3D3"
key="textField-2"
positionType="Float"
isRemoveLineWhenBlank="true"/>
<box topBorder="Thin" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="Thin" rightBorderColor="#000000" bottomBorder="Thin" bottomBorderColor="#000000"/>
<textElement verticalAlignment="Middle">
<font fontName="SansSerif" pdfFontName="Times-Bold" size="8" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[" "+$F{vesselName}+($F{type} == null ? "" : " ("+$F{type}+")")]]></textFieldExpression>
</textField>
Can you just tell us the properties you have set for the text fields?
I have just made a rough design of your scenario and I did not come across your issue. The row_count value is not getting repeated.
Refer below image.
Set a few properties to your variable:
<variable name="RECORD_COUNT" class="java.lang.String" incrementType="Column" calculation="Count">
<initialValueExpression><![CDATA[1]]></initialValueExpression>
</variable>