日期:2014-05-17 浏览次数:20970 次
<?xml version="1.0"?> <!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="FirstReport"> <detail> <band height="20"> <staticText> <reportElement x="20" y="0" width="200" height="20" /> <text><![CDATA[If you don't see this, it didn't work]]></text> </staticText> </band> </detail> </jasperReport>
JasperCompileManager.compileReportToFile("WebRoot/report/jasperreports_demo.jrxml", "WebRoot/report/langhua.jasper");
public static JasperReport compileReport("WebRoot/report/jasperreports_demo.jrxml")
public static void compileReportToStream(InputStream inputStream,OutputStream outputStream)
writeReportToXmlStream writeReportToXmlFile
public static JasperPrint fillReport(JasperReport jasperReport,Map parameters, JRDataSource dataSource)
//生成文件 public static void fillReportToFile( String sourceFileName, String destFileName, Map parameters, Connection connection ) //文件流 public static void fillReportToStream( JasperReport jasperReport, OutputStream outputStream, Map parameters, Connection connection )
JasperExportManager.exportReportToHtmlFile(jasperPrint, "c://1.html"); JasperExportManager.exportReportToPdfFile(jasperPrint, "c://1.pdf"); //还有很多方法的
JasperReport jasperReport; JasperPrint jasperPrint; try{ jasperReport = JasperCompileManager.compileReport("WebRoot/report/jasperreports_demo.jrxml"); jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(),new JREmptyDataSource()); JasperExportManager.exportReportToPdfFile(jasperPrint, "c://1.pdf"); } catch (JRException e){ e.printStackTrace(); }