0
以下jsp代碼不會生成任何excel文件。請幫忙。或者可以有人告訴我以其他方式將表數據從jsp/javascript導出到excel表單中?jexcel不工作
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.util.*"%>
<%@page language="java" import="java.sql.*"%>
<%@page language="java" import="pack.DbBean"%>
<%@ page import="java.io.*" %>
<%@ page import="jxl.*" %>
<%@ page import="jxl.write.*" %>
<%@ page import="jxl.Workbook" %>
<%@ page import="jxl.write.Label" %>
<%@ page import="jxl.write.WritableSheet" %>
<%@ page import="jxl.write.WritableWorkbook" %>
<jsp:useBean id="db" class="pack.DbBean" scope="session"/>
<%
try{
WritableWorkbook workbook = Workbook.createWorkbook(new File("output.xls"));
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
Label label = new Label(0, 2, "A label record");
sheet.addCell(label);
jxl.write.Number number = new jxl.write.Number(3, 4, 3.1459);
sheet.addCell(number);
workbook.write();
workbook.close();
}
catch(Exception e)
{
throw new ServletException("Exception in Excel Sample Servlet", e);
} finally
{
if (out != null)
out.close();
}
%>