并不是每一场导出excel都报错,只是偶尔。然后导出的excel表无法打开,也无法修复。
/**生成报表*/ String filename = "报表"+TimeUtil.getCurrentTime()+".xls";
try { filename = new String(filename.getBytes("GBK"), "ISO-8859-1"); } catch (UnsupportedEncodingException e) { logger.error("下载报表无效字符集"); } response.addHeader("Content-Disposition", "attachment;filename="+filename); response.setContentType("application/octet-stream"); OutputStream outputStream = null; try { outputStream = response.getOutputStream(); wb.write(outputStream);//------报错行-- outputStream.flush(); outputStream.close(); } catch (IOException e) { logger.error("下载报表异常:",e); }finally{ try { if(outputStream!=null){ outputStream.close(); } } catch (IOException e) { logger.error("下载报表流关闭异常"); } }
下面是报错信息:
java.net.SocketException: Socket closed at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:568) at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:539) at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:427) at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:298) at weblogic.servlet.internal.ChunkOutput$2.checkForFlush(ChunkOutput.java:648) at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:200) at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:148) at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:148) at java.io.OutputStream.write(OutputStream.java:58) at org.apache.poi.poifs.storage.BigBlock.doWriteData(BigBlock.java:67) at org.apache.poi.poifs.storage.DocumentBlock.writeData(DocumentBlock.java:195) at org.apache.poi.poifs.storage.BigBlock.writeBlocks(BigBlock.java:98) at org.apache.poi.poifs.storage.DocumentBlock.writeBlocks(DocumentBlock.java:34) at org.apache.poi.poifs.filesystem.POIFSDocument$BigBlockStore.writeBlocks(POIFSDocument.java:547) at org.apache.poi.poifs.filesystem.POIFSDocument.writeBlocks(POIFSDocument.java:303) at org.apache.poi.poifs.filesystem.POIFSFileSystem.writeFilesystem(POIFSFileSystem.java:385) at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1232)
添加回答
举报
0/150
提交
取消