本文主要是介绍easyexcel 数据量过大问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
java总的生成excel工具 poi太费事了,于是就是用来 阿里提供的 easyexcel 很简单,
具体使用方式参考:
https://zhuanlan.zhihu.com/p/88720415?utm_source=wechat_timeline
https://blog.csdn.net/weixin_30533109/article/details/112082439
https://blog.csdn.net/flipped___/article/details/107040213
今天在尝试导出数据的时候,经过几次测试发现,数据量超过5000,会页面会提示如下错误:
导出excel,异常com.alibaba.excel.exception.ExcelGenerateException: Can not close IO.at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:378)at com.alibaba.excel.write.ExcelBuilderImpl.finish(ExcelBuilderImpl.java:95)at com.alibaba.excel.ExcelWriter.finish(ExcelWriter.java:329)at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doWrite(ExcelWriterSheetBuilder.java:62)at com.iflytek.aiobs.report.controller.BusinessStatisticsReportController.export(BusinessStatisticsReportController.java:91)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at com.iflytek.sec.uap.client.rest.filter.VirtualFilterChain.doFilter(VirtualFilterChain.java:49)at com.iflytek.sec.uap.client.rest.filter.DecisionFilter.doFilter(DecisionFilter.java:102)at com.iflytek.sec.uap.client.rest.filter.VirtualFilterChain.doFilter(VirtualFilterChain.java:59)at com.iflytek.sec.uap.client.rest.filter.Cas20ProxyReceivingTicketValidationFilter.doFilter(Cas20ProxyReceivingTicketValidationFilter.java:96)at com.iflytek.sec.uap.client.rest.filter.VirtualFilterChain.doFilter(VirtualFilterChain.java:59)at com.iflytek.sec.uap.client.rest.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:78)at com.iflytek.sec.uap.client.rest.filter.VirtualFilterChain.doFilter(VirtualFilterChain.java:59)at com.iflytek.sec.uap.client.rest.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:92)at com.iflytek.sec.uap.client.rest.filter.VirtualFilterChain.doFilter(VirtualFilterChain.java:59)at com.iflytek.sec.uap.client.rest.filter.FilterChainProxy.doFilter(FilterChainProxy.java:110)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:151)at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:85)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:128)at org.springframework.boot.web.servlet.support.ErrorPageFilter.access$000(ErrorPageFilter.java:66)at org.springframework.boot.web.servlet.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:103)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)at org.springframework.boot.web.servlet.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:121)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.connector.ClientAbortException: java.io.IOException: Connection reset by peerat org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:330)at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:293)at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:118)at org.springframework.session.web.http.OnCommittedResponseWrapper$SaveContextServletOutputStream.flush(OnCommittedResponseWrapper.java:495)at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.flush(ZipArchiveOutputStream.java:979)at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)at org.apache.poi.xssf.streaming.SXSSFWorkbook.copyStreamAndInjectWorksheet(SXSSFWorkbook.java:509)at org.apache.poi.xssf.streaming.SXSSFWorkbook.injectData(SXSSFWorkbook.java:399)at org.apache.poi.xssf.streaming.SXSSFWorkbook.write(SXSSFWorkbook.java:939)at com.alibaba.excel.context.WriteContextImpl.finish(WriteContextImpl.java:339)... 97 common frames omitted
Caused by: java.io.IOException: Connection reset by peerat sun.nio.ch.FileDispatcherImpl.write0(Native Method)at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)at sun.nio.ch.IOUtil.write(IOUtil.java:65)at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:136)at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101)at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:157)at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1308)at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:692)at org.apache.tomcat.util.net.SocketWrapperBase.flushBlocking(SocketWrapperBase.java:645)at org.apache.tomcat.util.net.SocketWrapperBase.flush(SocketWrapperBase.java:635)at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.flush(Http11OutputBuffer.java:646)at org.apache.coyote.http11.filters.ChunkedOutputFilter.flush(ChunkedOutputFilter.java:166)at org.apache.coyote.http11.Http11OutputBuffer.flush(Http11OutputBuffer.java:252)at org.apache.coyote.http11.Http11Processor.flush(Http11Processor.java:1392)at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:403)at org.apache.coyote.Response.action(Response.java:206)at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:326)... 108 common frames omitted
在网上看了下这个报错:
com.alibaba.excel.exception.ExcelGenerateException: Can not close IO.
都是说jar问题,自己测试了下,数据量在2000一下的时候导出是正常的,应该还是数据量的问题,目前还在寻找解决方案中,有大神看到,烦请指点。
这篇关于easyexcel 数据量过大问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!