- public ActionForward action(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
- response.setContentType("application/vnd.ms-excel");
- response.addHeader("Content-Disposition", "attachment;filename=xsmd");
- HSSFWorkbook wb = new HSSFWorkbook();
- HSSFSheet sheet = wb.createSheet("new sheet");
- HSSFRow row = sheet.createRow(0);
- HSSFCell cell = row.createCell((short) 0);
- cell.setCellValue("id");
- cell = row.createCell((short) 1);
- cell.setCellValue("name");
- cell = row.createCell((short) 2);
- cell.setCellValue("age");
- ServletOutputStream os = response.getOutputStream();
- wb.write(os);
- os.flush();
- return null;
- }
使用poi生成Excel文件
最新推荐文章于 2024-05-07 15:35:31 发布