JasperReports NoClassDefFoundError exception on net.sf.jasperreports.engine.util.JRStyledTextParser

Finally, I’ve got it working. I detected the root Exception, which was thrown before NoClassDefFoundError:net/sf/jasperreports/engine/util/JRStyledTextParser : java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment The Sun AWT classes on Unix and Linux have a dependence on the X Window System. When you use these classes, they expect to load X client libraries and be able to talk to an X display … Read more

JasperReport – wrap text to show long text in textfield

I found the answer myself : I did some extra research about the properties of textField and rectangle components. And found that I need to set the following properties. For rectangle : <rectangle> <reportElement stretchType=”RelativeToBandHeight” … /> </rectangle> For textField : <textField isStretchWithOverflow=”true”> … </textField> Output as expected : The <detail> …</detail> section after correction … Read more

How to merge cells in same column, apply rowspan?

You can fairly easy achieve text vertically aligned at top by using isPrintRepeatedValues=”false”, setting borders correctly (only top, using empty cell with only left, adding line to columnFooter). To achieve “text vertically aligned at center” use a subreport for the other columns and set stretchType=”RelativeToBandHeight” on your rowspan column. Note you need in this case … Read more

JasperReports: How to call the report in jsp page

Compile the report in iReport Place the compiled report on the classpath load it with JasperReport jasperReport = (JasperReport) JRLoader.loadObject(inputStream); Fill it with data. dataSource is the DataSource instance you have – for example a BeanCollectionDataSource JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, dataSource); Export it JRPdfExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream); exporter.exportReport(); The outputStream above … Read more

How to show JRBeanCollectionDataSource data with help of Table component?

1.Send your datasource from the server as a parameter, and fill the report with a different one (can be empty). JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataList); Map parameters = new HashMap(); parameters.put(“INFO”, “Hello”); parameters.put(“DS1”, beanColDataSource); JasperReport report = (JasperReport) JRLoader.loadObject(“src/test/ireport/ShowPerson.jasper”); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource()); 2.Decalre a new parameter in the report of type … Read more