首页 新闻 会员 周边

poi导出excel文件时,如何设置生成文件的可读可写属性

0
悬赏园豆:20 [已解决问题] 解决于 2016-07-15 11:44

poi导出excel文件时,如何设置生成文件的可读可写属性

jx_nvli的主页 jx_nvli | 初学一级 | 园豆:184
提问于:2016-07-12 17:16
< >
分享
最佳答案
0

用File

file.setWritable (false);

收获园豆:20
laugher_ccc | 小虾三级 |园豆:593 | 2016-07-12 19:05

file.setReadOnly();  

laugher_ccc | 园豆:593 (小虾三级) | 2016-07-12 19:28

我这里用的是:

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=" + exportFilename);

/* OutputStream ouputStream = response.getOutputStream();
book.write(ouputStream);
ouputStream.flush();
ouputStream.close(); */
OutputStream ouputStream = null;
try{
ouputStream = response.getOutputStream();
book.write(ouputStream);
}catch(Exception e)
{
e.printStackTrace();
}finally{
ouputStream.close();
}

 

输出的,并没有file呀

jx_nvli | 园豆:184 (初学一级) | 2016-07-12 20:15

并且生成excel是自动就给加了一个只读,

jx_nvli | 园豆:184 (初学一级) | 2016-07-12 20:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册