Showing posts with label Jasper Report. Show all posts
Showing posts with label Jasper Report. Show all posts

Saturday, September 8, 2018

How to avoid merge cell in excel


The reason for that is the cell that is wrapping is increasing its height to fit the text, while the other cells in the same row are not doing the same thing. You should try setting the Stretch Type to Relative to Tallest Object and see if that helps.

Credit to https://stackoverflow.com/questions/9511353/jasperreports-merge-cells-exporting-to-xlsx?rq=1

Wednesday, July 18, 2018

How to remove extra row when exporting to Excel



  • Add net.sf.jasperreports.export.xls.remove.empty.space.between.columns and net.sf.jasperreports.export.xls.remove.empty.space.between.rows properties to report template.
net.sf.jasperreports.export.xls.remove.empty.space.between.columns - Specifies whether the empty spacer columns should be removed or not.
net.sf.jasperreports.export.xls.remove.empty.space.between.rows - Specifies whether the empty spacer rows should be removed or not.
The sample:
<jasperReport ...>
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/>
    <property name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows" value="true"/>
The information about configuration properties is here.
  • You can set isRemoveLineWhenBlank and isBlankWhenNull for textField element for hiding blank row.
The sample how to remove the whole line if the current textField is empty:
<textField isBlankWhenNull="true">
    <reportElement x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true"/>
    <textElement/>
    <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
  • Another assumption is to change the height of all textField (or/and staticText) elements in the Band.
In case this design:
design with a space between textField and the band's boundary
you will have a space between any two rows.
In case this design (textField height is equal to the Band's height): the textfield height is equal to the band's height
the each line will be exactly under the other.

Tuesday, March 6, 2018

How to Change Data Adapter Connection



Goto <JasperWorkspace>\.metadata\.plugins\com.jaspersoft.studio\dataAdapters


Open neccessary dataAdapter_* file and change its properties accordingly.

Then, restart your JasperStudio.

Friday, October 27, 2017

How to format numeric data in Excel



We can use net.sf.jasperreports.export.xls.detect.cell.type property for solving issue.
The quote from documentation:
net.sf.jasperreports.export.xls.detect.cell.type
Property whose value is used as default state of the IS_DETECT_CELL_TYPE export flag.
Specifies whether the exporter should take into consideration the type of the original text field expressions and set the cell types and values accordingly.
For example we can set this property for the whole report:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" ...>
    <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>

Wednesday, December 28, 2016

Bold a Word in single Static Text



1. Change Static Text Markup Properties to html
2. Place HTML bold tag at the target word. Eg: My <b>Bold</b> Text























Thursday, December 22, 2016

Directory Total Size



du -h -c directory|tail -1
*directory = your directory name

Monday, March 7, 2016

Jasper Report: How to draw vertical or horizontal line



Horizontal line
Drag line into design band. In this example, we are using Summary Band.
Change line height size to 1px
Vertical Line
Change line width size to 1px





Jasper Report: How to expand crosstab column header title



Below is the report output that we would like to achieve.











Goto Report XML source and add headerPosition = “Stretch” in the related columnGroup tag.
Below is the example:

<columnGroup name="TajukColumn1" height="20" totalPosition="End" headerPosition="Stretch">






















That’s all.

Jasper Report: How to change pattern expression conditionally



Below is the example of expression that can be used to change pattern expression conditionally.

IF(EXACT($P{myNumber},"Dollar"),
new java.text.DecimalFormat("#,##0.00").format($F{totalCost}),
         $F{totalCost}
)

* The above expression must be typed in Text Field Expression

Sunday, March 6, 2016

Jasper Report: How to divide BigDecimal number



The following example shows how to divide a BigDecimal format field.






















JumAset is a Jasper Report field with java.math.BigDecimal data type. Below is its screen shot:













Drag JumAset field into Detail Band. Below is the example:










Click at JumAset field under column header TOTAL OF ASSET IN MILLION, then go to Text Field expression and type the following expression:

$F{JumAset}.divide(new BigDecimal("1000000"))

Below is the screen shot:

Finally, compile and run the report and below is the example of output:















That’s all.

Saturday, March 5, 2016

Jasper Report: How to pass parameters to crosstab



In order to pass parameters into crosstab, first of all, we need to create parameters related in main report. Below is the example:




























After that, we need to create another 2 parameters in crosstab (crosstab parameters). Below is the example:

























                          Please ensure that all of the parameters in the main report and in crosstab section are using the same name and class. Below is the example:













Nevertheless, if you are using Jaspersoft Studio Community version, most of the time your IDE will have problem creating crosstab parameters. Therefore, alternatively you can create crosstab parameters in XML source and then assign crosstab parameters value with main report parameters value using <parameterValueExpression> tag. Below is the example:











                                           
Finally, compile and then run your report.

That’s all.

Jasper Report How To


  1. How to avoid merged cell in excel
  2. How to bold a word in a single Static Text
  3. How to change data adapter connection
  4. How to change patern expression
  5. How to divide BigDecimal number
  6. How to draw vertical or horizontal line
  7. How to expand crosstab column header
  8. How to format numeric data in Excel
  9. How to pass parameters to crosstab
  10. How to remove extra row when exporting to Excel