Creating report in java using jasper
Here is the example code for creating standalone java application to generate jasper report.
List dataList = new ArrayList();
HashMap dataMap = new HashMap();
dataMap.put("name", "ProductX");
dataMap.put("cost", 100.01);
dataList.add(dataMap);
dataMap = new HashMap();
dataMap.put("name", "ProductY");
dataMap.put("cost", 23.00);
dataList.add(dataMap);
dataMap = new HashMap();
dataMap.put("name", "ProductZ");
dataMap.put("cost", 99.89);
dataList.add(dataMap);
JasperDesign jasperDesign = getProductJasperDesign();
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JRBeanCollectionDataSource jrBeanCollectionDataSource = new JRBeanCollectionDataSource(dataList);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), jrBeanCollectionDataSource);
JasperViewer.viewReport(jasperPrint);
Click here to download example file.
October 20, 2008 | Filed Under Jasper
Related Post
Comments
Leave a Reply