I have a report controller having code:
@Controller
public class ReportsController {
@RequestMapping(value="report.htm",method=RequestMethod.GET)
public String showReport() throws JRException{
...
InputStream reportStream = this.getClass().getResourceAsStream("/report.jrxml");
JRDataSource dataSource = new JRBeanCollectionDataSource(reportData);
HashMap params = new HashMap();
params.put("Title", "Report");
JasperDesign jd = JRXmlLoader.load(reportStream);
JasperReport jr = JasperCompileManager.compileReport(jd);
JasperPrint jp = JasperFillManager.fillReport(jr, params, dataSource);
JRHtmlExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
//EXPORTING REPORT TO A FILE "myreport.html"
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "E:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html"); //--------statement (1)
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, false);
exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, true);
exporter.exportReport();
return "report";
}
}
In statement (1) I am exporting my generated report to a file myreport.html.
My report template file (report.jrxml) is:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report5" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<field name="count" class="java.lang.Integer"/>
<field name="status" class="java.lang.String"/>
<background>
<band/>
</background>
<detail>
<band height="343">
<textField>
<reportElement mode="Transparent" x="8" y="14" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{count}]]></textFieldExpression>
</textField>
<textField>
<reportElement mode="Transparent" x="267" y="14" width="100" height="20"/>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{status}]]></textFieldExpression>
</textField>
<staticText>
<reportElement mode="Transparent" x="146" y="14" width="100" height="20"/>
<textElement/>
<text><![CDATA[status]]></text>
</staticText>
<barChart>
<chart>
<reportElement mode="Transparent" x="108" y="119" width="200" height="100"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[""]]></seriesExpression>
<categoryExpression><![CDATA[$F{status}]]></categoryExpression>
<valueExpression><![CDATA[$F{count}]]></valueExpression>
<itemHyperlink/>
</categorySeries>
</categoryDataset>
<barPlot>
<plot/>
</barPlot>
</barChart>
</band>
</detail>
</jasperReport>
Problem is that my generated report in myreport.html
is showing everything but does not show any bar chart, instead showing blank white space in place of chart.
Any suggestions?
EDIT:
Data to chart is provided by statement JasperPrint jp = JasperFillManager.fillReport(jr, params, dataSource);
in the above code.
Moreover there is a folder generated, by jasper reports API, in the same dir in which there is my output file (myreport.html) lies as:
/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html (Output file)
/mywebapp/WEB-INF/jsps/reports/reportsOutput/myreport.html_files (generated folder)
This generated folder (myreport.html_files) contains generated chart images according to template and are correct but these chart images are not being shown up in the output file myreport.html along with other text output of report. Thanks...
exporting of jasper reports containing charts to a html file
. i labelled it as spring as i m using jasper reports in spring controller. – a Learner