双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

JAVA 使用JXL导出EXECL怎么选择路径 求改

vigoss1280 vigoss1280 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
引用
public String printCustomerDetails() throws Exception{
List<CustomerDetails> printCustomerDetailsListInformation=customerDetailsBizImpl.CustomerDetailsGetAllRecord(
(String)session.getAttribute("customerDetailsGetSmcdClientCode"),
(String)session.getAttribute("customerDetailsGetSmcdName"),
(String)session.getAttribute("customerDetailsGetSmcdTheCompanyProperites"),
(String)session.getAttribute("customerDetailsGetSmcdWayToTrade"),
(String)session.getAttribute("customerDetailsGetSmcdQualityRating"),
(String)session.getAttribute("customerDetailsGetSmcdCreationTime"),
(String)session.getAttribute("customerDetailsGetSmcdModificationTime"));

session.setAttribute("printCustomerDetailsListInformation", printCustomerDetailsListInformation);
List clients=(List)session.getAttribute("printCustomerDetailsListInformation");
Excel ex=new Excel();

try {
String tempfileName = new String("项目报表.xls".getBytes("GBK"),"ISO8859_1");
response.setContentType("application/vnd.ms-excel");
response.setHeader("ContentDisposition", "attachment;filename="+tempfileName);
String webPath = request.getSession().getServletContext().getRealPath("/");
System.out.println(webPath);
//创建一个存放下载文件的临时目录
String tempFile = "tempDownLoad";
File f= new File(webPath + "/" + tempFile);
if(!f.exists()){
f.mkdirs();
}
ex.writeExcelCustomerContact(new FileOutputStream(f), clients);

} catch (Exception e1) {
e1.printStackTrace();
throw new RuntimeException("数据导出时发生错误!",e1);
}
return "success";
}

运行到下面就报错
response.setContentType("application/vnd.ms-excel");
response.setHeader("ContentDisposition", "attachment;filename="+tempfileName);
...全文
评论
收藏 已收藏
分享
返回顶部
vigoss1280
其他 10,612 成员 29,026 内容