Java – import CSV data using Apache poi
How to effectively import CSV data through Apache POI? If I have a very large CSV file that I want to store in my Excel spreadsheet, I won't imagine whether cell by cell is the best way to import?
Solution
Apache POI has never been designed to invoke CSV files Although CSV files may be opened in Excel, excel has its own reader for automatic import This assumes that your CSV has CSV instead of Txt suffix If it has Txt suffix and save it as csv. All you need to do is right-click CSV and open with Excel Presto, CSV imported into excel
I suppose you want to parse the data from a TXT file into an excel file If so, I suggest you use library like superscsv instead of trying to make POI do something that has never been designed It will load it all into the bean, map or list you choose, because it can parse the data, and then you can write it in the format you choose CSV file or use JDBC - ODBC bridge or Apache POI to write it directly into and Xls format Add an extra step, but you have complete control over the data
Supercsv carries the Apache 2 license, so it should be good for anything you choose
Or just use it in Java Split() function, parse CSV into an array, and use POI to load the array into Xls