日期:2014-05-17  浏览次数:20758 次

从一个jsp的查询网址导出查询到的数据
一个人员管理网址,

查询到的人,每页20个,有若干页

不提供导出花名册功能,有什么办法把查到的数据导出到excel或其他中

excel的新建web查询不能,查询的那个小窗口不出现黄色的那个符号
jsp??网站??导出?

------解决方案--------------------
导出excel,用jxl不就行了。
------解决方案--------------------

用的poi

HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
ByteArrayOutputStream bao = null;
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet;
HSSFRow row;
HSSFCell cell;
sheet = workbook.createSheet();
row = sheet.createRow(0);
cell = row.createCell(0);
cell.setCellValue("第一行第一列");
cell = row.createCell(1);
cell.setCellValue("第一行第二列");
cell = row.createCell(2);
cell.setCellValue("第一行第三列");
cell = row.createCell(3);
cell.setCellValue("第一行第四列");
cell = row.createCell(4);
cell.setCellValue("第一行第五列");
cell = row.createCell(5);
cell.setCellValue("第一行第六列");
for (int i = 0; i < 30000; i++) {
row = sheet.createRow(i + 1);
cell = row.createCell(0);
cell.setCellValue("123");
cell = row.createCell(1);
cell.setCellValue("123");
cell = row.createCell(2);
cell.setCellValue("123");
cell = row.createCell(3);
cell.setCellValue("");
cell = row.createCell(4);
cell.setCellValue("");
cell = row.createCell(5);
cell.setCellValue("123");
}

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
response.setContentType("application/octet-stream");
response.setHeader("Content-length", workbook.getBytes() + "");
String filename = new String((sdf.format(new Date()) + "tt.xls")
.getBytes("GBK"), "iso8859-1");
response.setHeader("Content-disposition", "attachment; filename="
+ filename);
OutputStream reponseOs = response.getOutputStream();
workbook.write(reponseOs);
reponseOs.flush();
reponseOs.close();
response.flushBuffer();


------解决方案--------------------
顶楼上,用poi