怎么把iReport生成的报表导出为word文档格式.doc
我试了一下 只生成了报表图 没有文字和表格
-----------------------word
exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST,jasperPrintList);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"D://allreport.doc");
exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "GGB2312");
exporter.exportReport();
ireport 导出word格式
导出word格式 在它的文档中也没有,
// String sql = "select * from cfg_static_user_relation"; 如果传SQL语句的话用该句
String ReportModel ="/test/test.jasper";
File reportFile = new File(application.getRealPath(ReportModel));
System.out.println(reportFile);
if(!reportFile.exists())
throw new JRRuntimeException("报表绘制失败,找不到报表配置文件!");
JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
// Connection conn=null;
// conn=JdbcConnectionFactory.getConnection();
Collection coll = UserService.generalCollecion();
JRDataSource sor = new JRBeanCollectionDataSource(coll);
System.out.println(application.getRealPath("test/1224215057359.png"));
Map parameters = new HashMap();
parameters.put("re",application.getRealPath("test/1224215057359.png"));
// JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport ,parameters,conn);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport ,parameters,sor);
JRExporter exporter = new JRRtfExporter();
String tmpFilename = System.currentTimeMillis() + ".doc";
response.setContentType("application/msword;charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+tmpFilename);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
exporter.exportReport();
这样就可以导出WORD格式了