然后
OutputStream os = null
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet")
response.setHeader("Content-Disposition","attachmentfilename=" + URLEncoder.encode("供应商信息"+new Date().toString(), "UTF-8") + ".xslx") //以下载形式,如果是直接在线打开
// response.setHeader("Content-Disposition","inlinefilename=" ......
//中文文件名请适当转码,后缀名根据创建workbook时的版本决定(2003-HSSFWorkbook-.xls;2007-XSSFWorkbook-.xlsx)
os = response.getOutputStream()
workbook.write(os)
response.flushBuffer()
(io流的关闭和io异常扑捉自行处理,poi生成excel的过程参照poi文档,无非就是sheet,row,cell的操作)
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)