jasperreport5.6.0生成报表另存为XML格式

前端之家收集整理的这篇文章主要介绍了jasperreport5.6.0生成报表另存为XML格式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Jasperreport5.6.0生成的报表,可有多种格式,这里主要讲生成 PDFRTFEXCELHTMLXML等格式,这里讲生成EXCEL格式的,在JSP页面代码,如下所示:

<%@ page language="java" import="java.util.*"pageEncoding="UTF-8"%>

"net.sf.jasperreports.engine.*" "net.sf.jasperreports.engine.export.*"%>

"org.springframework.ui.jasperreports.JasperReportsUtils""java.util.*" "java.io.*" "java.sql.*" <%

String path =request.getContextPath();

String basePath =request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<%

//报表生成之后编译生成.jasper文件位置

File jasperFile=new File("D:/Workspaces/zwjxSystem/WebRoot/jasper/report1.jasper");

String url ="jdbc:oracle:thin:@192.168.1.104:1521:orcl";

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection conn =DriverManager.getConnection(url,"zwjx",255); font-family:'Courier New'">"zwjx");

String projectapproid =request.getParameter("projectapproid");

Map map = new HashMap();

map.put("projectapproid",projectapproid);

//打印

JasperPrintprint = JasperFillManager.fillReport(jasperFile.getPath(),map,conn);

OutputStream os=response.getOutputStream();

生成文件

StringfileNames="项目立项";

JRAbstractExporter exporter = new JRXmlExporter();

response.reset();

response.setHeader("Content-Disposition",255); font-family:'Courier New'">"attachment;filename="+new String(fileNames.getBytes("gbk"),255); font-family:'Courier New'">"iso8859-1")+".xml");

JasperReportsUtils.render(exporter,print,os);

os.flush();

os.close();

%>

运行后,弹出如下对话框,我们可以根据需要选择。可以直接打开,也可以保存。



猜你在找的XML相关文章