Java export CSV file
In the past, POI was always used to export as Excel file. Later, when I learned about CSV, I found that the speed was very fast.
If the exported data does not require format, style, formula, etc., it is recommended to export it to CSV file, because it is really fast.
Although we can use the file related classes brought by java to generate a CSV file, in fact, many third-party class libraries also provide similar functions.
Here we use the Commons CSV component provided by Apache
Commons CSV
The document is here
http://commons.apache.org/
http://commons.apache.org/proper/commons-csv/
http://commons.apache.org/proper/commons-csv/user-guide.html
Let's look at the specific usage first
CSV and excel
Maven dependency
Finally, in the example just now, only three fields and one million lines are written, and the generated CSV file has more than ten or twenty megabytes. If there are too many, it is recommended to package multiple files next week, otherwise it will be difficult to imagine opening a few hundred megabytes of Excel.