api导出excel不同格式的方法

excel的格式分为三种:excel2003,excel2007 和openxml。
当数据量比较多的时候,建议使用导出2007 或者是 openxml的格式。
以下是  2003 的代码示例。


<%@ page contentType="text/html;charset=GBK"%>
<%@ taglib uri="/WEB-INF/runqianReport4.tld" prefix="report"%>
<%@ page import="com.runqian.report4.model.*"%>
<%@ page import="com.runqian.report4.usermodel.*"%>
<%@ page import="com.runqian.report4.util.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="com.runqian.report4.view.html.*"%>

<html>
<body topmargin=0 leftmargin=0 rightmargin=0 bottomMargin=0>
<%
//第一步,读取报表模板
InputStream fis = application.getResourceAsStream("/reportFiles/aa.raq");   
ReportDefine rd = (ReportDefine) ReportUtils.read(fis);
//第二步,运算报表
Context context = new Context();
Engine enging = new Engine(rd, context);
IReport iReport = enging.calc();
//导出
String fileName = "E:/123.xls";     //指定导出的excel的文件目录和名称
try {        
   ReportUtils.exportToExcel(fileName, iReport, true,200);
   out.print("导出完成!");  
} catch (Throwable e) {
e.printStackTrace();
}
request.setAttribute("ireport",iReport);
%>
<table align=left>
       <tr><td>
                     <report:html name="report1"
                     srcType="defineBean"
                     beanName="ireport"
                     funcBarLocation="top"
                     exceptionPage="/reportJsp/myError.jsp"
              />
       </td></tr>
</table>
</body>
</html>

导出excel2003的格式方法:


导出openxml的格式方法:

导出excel2007 的格式方法:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值