POI 导出Excel表格 输出数据流 博客分类: Java POI 导出Excel表格 输出数据流
程序员文章站
2024-03-15 13:32:11
...
FileOutputStream fileOut = new FileOutputStream("E:/workbook.xls"); workbook.write(fileOut); fileOut.close();
pName="*****"; response.reset(); response.setContentType("application/x-msdownload"); response.setHeader("Content-Disposition","attachment;filename="+new String(pName.getBytes("gb2312"),"ISO-8859-1")+".xls"); ServletOutputStream outStream=null; try{ outStream = response.getOutputStream(); wb.write(outStream); }catch(Exception e) { e.printStackTrace(); }finally{ outStream.close(); }
{ HSSFWorkbook workbook = ExportToExcel.userExportToExcel(list); HttpServletResponse response = ServletActionContext.getResponse(); String fileName = "***.xls"; response.setContentType("application/octet-stream"); response.setHeader("name", fileName); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setDateHeader("Expires", 0); response.setHeader("Content-disposition","attachment; filename=\""+URLEncoder.encode(fileName, "UTF-8")+ "\""); workbook.write(response.getOutputStream()); // 输出流控制workbook response.getOutputStream().flush(); response.getOutputStream().close(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
上一篇: Logstash 入门 学习 (一) logstash
下一篇: 解决一个页面显示问题
推荐阅读
-
POI 导出Excel表格 输出数据流 博客分类: Java POI 导出Excel表格 输出数据流
-
java poi导出Excel Demo 博客分类: Java java poi导出Excel Demo
-
POI导出Excel表格,去掉数字框的左上角绿色的小三角 博客分类: Java POI导出Excel表格去掉数字框的左上角绿色的小三角
-
Java利用POI实现导入导出Excel表格示例代码
-
Java利用POI实现导入导出Excel表格示例代码
-
java中导入导出Excel表格(jxl的API应用) 博客分类: java ExcelJava应用服务器工作浏览器
-
java中导入导出Excel表格(jxl的API应用) 博客分类: java ExcelJava应用服务器工作浏览器
-
java poi导出Excel表格超大数据量解决方案
-
JAVA POI HSSFWorkbook 导出Excel表格超大数据量解决方案