0

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 :

  1. cell to stretch as per the length of the data or
  2. want the data inside the cell to not get cropped or
  3. any better way to give proper alignment

Note : i tried width= "150" , still the same result

Alex K
  • 22,315
  • 19
  • 108
  • 236
Avinash S
  • 1
  • 1
  • From the image it appears your data contains just random characters without any space. Normally wrap text occurs for words. Anyways, Can you post actual data from which this output is resulting. Anyways, if you want some space at left and right of column you can specify 'Left Indent' and 'Right Indent – Syed Asad Manzoor Nov 22 '22 at 11:48
  • hi @SyedAsadManzoor , so basically the uom field can have max 45 characters, it doesn't need to be a words, it is supposed to be random charactesr but only 45 characters max. can you tell me exactly where to use left indent and right indent in the code(I'm a beginner) , thanks – Avinash S Nov 22 '22 at 11:54
  • Then adding Indent on both sides (Left Indent , Right Indent) to 2 or more will solve ur prbolem. From the image i guess data appears to be 'cropped' as it touches left and right margins. – Syed Asad Manzoor Nov 22 '22 at 12:01
  • @SyedAsadManzoor exactly, the data appears cropped, can you please modify the code and add it in the comment (please note I'm just starting jasper), also I added another picture of the report. – Avinash S Nov 22 '22 at 12:11
  • which version of jasper you are using as it is not compiling at my end. Have you posted the complete XML? – Syed Asad Manzoor Nov 22 '22 at 12:14
  • @SyedAsadManzoor version 6.18.1.final, no its not the complete file. complete file has more than 500 lines – Avinash S Nov 22 '22 at 12:31
  • im not able to add the complete file. – Avinash S Nov 22 '22 at 12:41

1 Answers1

0

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

  • i tried the above solution, but its still the same, in the picture if you see the left and right has some space , but the top and bottom is cropped. 1) the report has total 15 columns(kpi, uom, weightage....etc) should I add < paragraph leftIndent="5" rightIndent="5"/ > for all 15. – Avinash S Nov 22 '22 at 13:28
  • for top and bottom adjust detail cell height as it is currently: jr:detailCell style="Table_TD" height="15" try to set height ="20" or more.. and as u have already set vertical alignment to middle i think setting height > 15 will result in top and bottom margin – Syed Asad Manzoor Nov 22 '22 at 13:48
  • i set height = "25" , but the data is croped at the bottom , I attached a pic , please look into it. – Avinash S Nov 22 '22 at 15:00