Achieve million lines of class excel export --- poi - ooxm applications and Pit

xl_echo edited, welcome to reprint, please declare the source of the article. Welcome to add echo micro letter (Micro Signal: t2421499075) the exchange of learning. Battle undefeated, according to not claiming victorious, defeat after defeat is not decadent, according to energy struggling to move forward. - This is the real rated power! ! --- ##### reading suggestions: If you have not done related to import and export, but also need to read the bottom of this magnitude can directly poi-ooxm application> excel using poi direct export is the maximum number? Estimated that many people are not concerned about this issue, because there is little direct business requires excel export thousands of pieces of data, or worse still may not have heard excel 100w direct export of data. Here to introduce a reference to the scene and bloggers pit mining experience. #### describes the company needs required to achieve export feature a bank of water, looked like a simple button, but the demand there are several requirements: - Export file formats need to xlsx - the minimum amount for each export 5w strip, and a table - the time needed to export the file download form the browser to download> landlord development environment: jdk1.8, idea2018.1, springboot1.5x, dubbox #### for the first try poi-3.9 is just the beginning time, not too much attention to this article 5w number, poi-3.9 directly. Throughout the development process basically no problem encountered. During the test, we encountered a problem that can not meet the demand. When I downloaded directly 5w article, the program directly error. After continuous testing, we found that the direct use of 3.9, the maximum value of 6000 + download (the highest value and computer performance have a certain relationship, but access will not be great). ###### test results poi-3.9 6000+ ceiling> Clearly not above trying to make a demand-related functions, through Baidu, found easyexcel is a good solution. For the #### attempt to import easyexcel easyexcel is `` `xml com.alibaba easyexcel 1.1.1 `` `Dependent on the use of the time, I made reference to that blogger's code, the code address is: https: //blog.csdn.net/qq_35206261/article/details/88579151. When I took him to the level of millions of lines of solutions to move my project, I found everything seems to be no problem. But when I started finding has been given java.lang.NoSuchMethodError: org.apache.poi.ss.usermodel.Font.setBold (Z) V. (Where the error comes from the company's project dependent on the original project into conflict, if not done import and export related functions should not appear). After investigation found problems in reliance on it. The company has introduced originally dependent on import and export functions are as follows: `` `xml org.apache.poi then-OOXML 3.9 `Conflict as shown below:! [FIG 1] (https://img-blog.csdnimg.cn/20190730172303517.png) ##### poi-ooxml a pit not backward compatible with the click-dependent enter easyexcel We find that it is dependent on the underlying version of poi3.17. When I always thought poi is backward compatible, the problem occurs every time you start the final compilation and when they are not pointing downward compatible. poi-ooxml underlying version 3.17, as shown in FIG! [FIG 2] (https://img-blog.csdnimg.cn/20190730172314831.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hsZWNobw ==, size_16, color_FFFFFF, t_70) this time we can use if we still have to easyexcel, then we need to change the version or versions of poi-ooxml resolve compatibility issues. > After incompatibility issues, see the company's original applied poi-ooxml is determined using poi-ooxml solutions. #### poi-ooxml application after more than a few pit, and decided to use the 3.9 version of poi-ooxml compatible solution, after Baidu found to have a 3.8 version of the application to the foundation. After not compatible with the above, I decided to give it a try. So using a piece of code that bloggers article, article address: https: //blog.csdn.net/happyljw/article/details/52809244. This article describes in an idea, but also gives implementation code provided by some bloggers, relatively speaking, if not as a test question, and finally adjusted according to demand, to modify some of the steps to achieve, but also new and implement some new restrictions. Code is as follows: `` `java @ResponseBody @RequestMapping (value =" setContentType ( "application / vnd.ms-excel; charset = utf-8"); response.setHeader ( "Content-Disposition", "attachment; filename =" + fileName + ".xlsx"); ServletOutputStream outputStream = response.getOutputStream (); wb.write (outputStream); outputStream.flush (); outputStream.close ();} `` `here simplifies the operation of the data source, if required can be modified according to their business, in my actual implementation of the review the operation data source is relatively, not only a segment request (dubbox avoid time-out), but also a lot of data processing. The operations here have a bright spot that had divided the multi Sheet. ##### Note: This development environment is jdk1.8 after the completion of the above code when writing, use of tools tested and found to have realized the features I need. Current downloads within a 10w are not much of a problem, 10w measured data 20s. If the business logic is simpler but also doubled the speed. #### Summary: - million lines of class, there are two solutions - * poi-ooxml - * easyexc - If you use one of a certain kind of pay attention to whether the introduction of another, may not be compatible. - poi-ooxml3.9 and poi-ooxml3.17 not perfectly backwards compatible - poi3.17 maximum peak download 6000+ ServletOutputStream outputStream = response.getOutputStream (); wb.write (outputStream); outputStream.flush (); outputStream.close ();} `` `herein simplifies the operation of the data source, if required can be modified according to their service, I in the actual implementation of the data source relative review operation, not only a segment request (dubbox avoid time-out), but also a lot of data processing. The operations here have a bright spot that had divided the multi Sheet. ##### Note: This development environment is jdk1.8 after the completion of the above code when writing, use of tools tested and found to have realized the features I need. Current downloads within a 10w are not much of a problem, 10w measured data 20s. If the business logic is simpler but also doubled the speed. #### Summary: - million lines of class, there are two solutions - * poi-ooxml - * easyexc - If you use one of a certain kind of pay attention to whether the introduction of another, may not be compatible. - poi-ooxml3.9 and poi-ooxml3.17 not perfectly backwards compatible - poi3.17 maximum peak download 6000+ ServletOutputStream outputStream = response.getOutputStream (); wb.write (outputStream); outputStream.flush (); outputStream.close ();} `` `herein simplifies the operation of the data source, if required can be modified according to their service, I in the actual implementation of the data source relative review operation, not only a segment request (dubbox avoid time-out), but also a lot of data processing. The operations here have a bright spot that had divided the multi Sheet. ##### Note: This development environment is jdk1.8 after the completion of the above code when writing, use of tools tested and found to have realized the features I need. Current downloads within a 10w are not much of a problem, 10w measured data 20s. If the business logic is simpler but also doubled the speed. #### Summary: - million lines of class, there are two solutions - * poi-ooxml - * easyexc - If you use one of a certain kind of pay attention to whether the introduction of another, may not be compatible. - poi-ooxml3.9 and poi-ooxml3.17 not perfectly backwards compatible - poi3.17 maximum peak download 6000+ 8 After completion code when writing the above, the use of test tools, has been found to achieve the functionality I need. Current downloads within a 10w are not much of a problem, 10w measured data 20s. If the business logic is simpler but also doubled the speed. #### Summary: - million lines of class, there are two solutions - * poi-ooxml - * easyexc - If you use one of a certain kind of pay attention to whether the introduction of another, may not be compatible. - poi-ooxml3.9 and poi-ooxml3.17 not perfectly backwards compatible - poi3.17 maximum peak download 6000+ 8 After completion code when writing the above, the use of test tools, has been found to achieve the functionality I need. Current downloads within a 10w are not much of a problem, 10w measured data 20s. If the business logic is simpler but also doubled the speed. #### Summary: - million lines of class, there are two solutions - * poi-ooxml - * easyexc - If you use one of a certain kind of pay attention to whether the introduction of another, may not be compatible. - poi-ooxml3.9 and poi-ooxml3.17 not perfectly backwards compatible - poi3.17 maximum peak download 6000+

Guess you like

Origin www.cnblogs.com/xlecho/p/11271506.html