struts action实现jsp下载excel



public String exportBiddingReport()  throws Exception{
Map condition=new HashMap();
if(approveStartDate!=null&&approveStartDate.length()>7)
condition.put("approveStartDate", approveStartDate);
if(approveEndDate!=null&&approveEndDate.length()>7)
condition.put("approveEndDate", approveEndDate);
bidingList=reportService.getBidingReport(condition);
String fileName=this.getClass().getClassLoader().getResource(" ../../download/招投标信息表.xls").getPath();
InputStream inputStream=new FileInputStream(fileName);
HSSFWorkbook hwb=new HSSFWorkbook(inputStream);
HSSFSheet hs=hwb.getSheetAt(0);
for(int i=0;i<bidingList.size();i++){
HSSFRow hr=hs.createRow(i+1);
Map map=(Map)bidingList.get(i);
HSSFCell cell=hr.createCell((short)0);
cell.setCellValue(map.get("CODE").toString());
cell=hr.createCell((short)1);
if(map.get("APPROVE_DATE")!=null)
cell.setCellValue(map.get("APPROVE_DATE").toString());
cell=hr.createCell((short)2);
if(map.get("PROJEC_NAME")!=null)
cell.setCellValue(map.get("PROJEC_NAME").toString());
cell=hr.createCell((short)3);
if(map.get("BUDGET_VALUE")!=null)
cell.setCellValue(map.get("BUDGET_VALUE").toString());
cell=hr.createCell((short)4);
if(map.get("SIGN_DATE")!=null)
cell.setCellValue(map.get("SIGN_DATE").toString());
cell=hr.createCell((short)5);
if(map.get("CONSTRACT_VALUE")!=null)
cell.setCellValue(map.get("CONSTRACT_VALUE").toString());
cell=hr.createCell((short)6);
if(map.get("BUYTYPE")!=null)
cell.setCellValue(map.get("BUYTYPE").toString());
cell=hr.createCell((short)7);
if(map.get("VENDORNAME")!=null)
cell.setCellValue(map.get("VENDORNAME").toString());
cell=hr.createCell((short)8);
if(map.get("CONTACT")!=null)
cell.setCellValue(map.get("CONTACT").toString());
cell=hr.createCell((short)9);
if(map.get("CONTACTCHANNEL")!=null)
cell.setCellValue(map.get("CONTACTCHANNEL").toString());
cell=hr.createCell((short)10);
if(map.get("SUCCESS_DATE")!=null)
cell.setCellValue(map.get("SUCCESS_DATE").toString());
cell=hr.createCell((short)11);
if(map.get("SUCCESS_CAUSE")!=null)
cell.setCellValue(map.get("SUCCESS_CAUSE").toString());
cell=hr.createCell((short)12);
if(map.get("JUDGE_NUMBER")!=null)
cell.setCellValue(map.get("JUDGE_NUMBER").toString());
cell=hr.createCell((short)13);
if(map.get("MEETING_NUMBER")!=null)
cell.setCellValue(map.get("MEETING_NUMBER").toString());
cell=hr.createCell((short)14);
if(map.get("PROJECTTYPE")!=null)
cell.setCellValue(map.get("PROJECTTYPE").toString());
cell=hr.createCell((short)15);
if(map.get("SPEC")!=null)
cell.setCellValue(map.get("SPEC").toString());
cell=hr.createCell((short)16);
if(map.get("PRICE")!=null)
cell.setCellValue(map.get("PRICE").toString());
HSSFCellStyle style=hwb.createCellStyle();
style.setWrapText(true);
hs.setColumnWidth((short)17, (short)3766);
hs.setColumnWidth((short)18, (short)3766);
cell=hr.createCell((short)17);
cell.setCellStyle(style);
if(map.get("invite")!=null)
cell.setCellValue(map.get("invite").toString());
cell=hr.createCell((short)18);
cell.setCellStyle(style);
if(map.get("CONTRACT_MEMO")!=null)
cell.setCellValue(map.get("CONTRACT_MEMO").toString());
}
String downLoadName="招投标信息表.xls";
downLoadName=new String(downLoadName.getBytes(),"ISO8859-1");
response.setHeader("Content-disposition", "attachment;filename=".concat(downLoadName));
response.setContentType("application/x-download");
ServletOutputStream sos=response.getOutputStream();
hwb.write(sos);
return null;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值