日期:2014-05-16 浏览次数:20356 次
使用jxl的话可以参考如下代码
在action中加入
response.setContentType("application/vnd.ms-excel;charset=GBK");
response.setHeader("Content-disposition", "attachment; filename=" + "test.xls");
OutputStream os = response.getOutputStream();
jxl.write.WritableWorkbook wwb = Workbook.createWorkbook(os);
。。。。。
wwb.write();
wwb.close();
使用poi的话参考
response.setContentType("application/vnd.ms-excel;charset=GBK");
response.setHeader("Content-disposition", "attachment; filename=" + "test.xls");
OutputStream os = response.getOutputStream();
HSSFWorkbook workBook = new HSSFWorkbook();
workBook.write(os);
os.flush();
os.close();