Jquery 可以导出word么
发布网友
发布时间:2022-06-08 08:55
我来回答
共1个回答
热心网友
时间:2023-11-18 12:13
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格式了
--------------------------------------------------------------------------------
提问者对于答案的评价:
我的已经出来了‘
哎
我用的是金山的WSP办公
换了office的就可以了