CSV描述:
用于数据导出
Action核心代码:
StringBuffer csvString=new StringBuffer();
csvString.append("args1"+",");
csvString.append("args2"+"/n");
Excel描述:
使用org.apache.poi包;
Action核心代码:
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Plan Sectoin");
HSSFRow row0 = sheet.createRow((short)curRow);
row0.createCell((short)0).setCellValue(new HSSFRichTextString("Plan Section Detail"));
response.setContentType("application/x-download"); //application/x-download
String filenamedisplay = "plan" + ".xls";
response.addHeader("Content-Disposition", "attachment;filename=" + filenamedisplay);
OutputStream 或者可以是【ServletOutputStream】 os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();