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

vigoss1280 2013-01-17 11:26:57
引用
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);
...全文
65 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

10,612

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧