导出Excel文件用类CachedRowSet报错
我们的项目要部署到jdk1.4的版本上,我要生成Excel文件,但是下面的代码在安装了jdk1.6的机子上(我在MyEclipse里设置的jdk5.0)运行正常,但是在安装成jdk1.4以后就报异常,我怎么改才能解决,请教高手指点
java代码:
CachedRowSet crs = this.GetResult(sql);
WritableWorkbook wwb = null;
try {
wwb = Workbook.createWorkbook(os);
jxl.write.WritableSheet ws = wwb.createSheet("Sheet1",1);
int i = 1;
while (crs.next()) {
for (int j = 1; j <= crs.getMetaData().getColumnCount(); j++) {
String s = crs.getString(j);
Label labelC = new Label(j-1, i, s);
ws.addCell(labelC);
}
i++;
}
异常:
javax.servlet.ServletException: javax/sql/rowset/CachedRowSet
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.excel_jsp._jspService(excel_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoClassDefFoundError: javax/sql/rowset/CachedRowSet
org.apache.jsp.excel_jsp._jspService(excel_jsp.java:54)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
jsp代码:
out.print(request.getParameter("sql"));
Excel excel=new Excel();
response.reset();
response.setContentType("application/vnd.ms-excel");
String sql=request.getParameter("sql");
excel.getExcelResult(sql,response.getOutputStream());
------解决方案--------------------
你的包有没有导入呀?
看你的代码至少要导入两个包
------解决方案--------------------
就是Rowset.jar
多百度几次吧....
------解决方案--------------------
有没有重新编译一下