Apache POI was never designed to call on CSV files. While a CSV File may be opened in Excel, Excel has its own reader that does an auto import. This is assuming that your CSV has the .csv
instead of the .txt
suffix. If it has the .txt
suffix, save it as a .csv.
All then you have to do is right click on the CSV and Open With Excel. Presto, the CSV has been imported into Excel.
I am assuming that you are wanting to parse the data from a txt file into the Excel File. If that is the case I would suggest you use a Library like SuperCSV instead of trying to get POI to do something it was never designed to do. It will load it all into a Bean, Map or List of your choice as it parses the data and then you can either write it back in the format you chose into a .csv
file or use a JDBC-ODBC Bridge or Apache POI to write it directly into and .XLS
format. Adds an extra step, but then you have complete control of the data.
SuperCSV carries the Apache2 License, so it should be good for anything you choose to do with it.
Or just use the split
function in Java and parse up the CSV into arrays and load the arrays into .xls
with POI.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…