I have requirement to import Excel file in MySQL database using Java. I Googled it and got the answer is to export CSV files from Excel then import it usingLOAD DATA LOCAL INFILE 'SampleData.csv' INTO TABLE databasetable FIELDS TERMINATED BY ','
. It works nicely.
I have doubts why we convert Excel files to CSV then import file into an da开发者_如何转开发tabase. Is there is another technique to import Excel without converting into CSV?
Thanks
Try Apache POI.
http://poi.apache.org/
More info on why POI is possibly better than JExcel and other alternatives:
Which is better open source for Excel file parsing in Java?
CSV is a plaintext file format showing the contents of the Excel file as Comma Separated Values (CSV)
This is done so that the Java program need not know how to parse the Excel Files themselves, which is a big bonus.
Consider the recent change that Office underwent with the Office 2007 release. Their new file format .xlsx
was not backwards compatible with their former .xls
format. This is because the .xlsx
format compressed the contents.
If your program parsed the .xls
files directly, it would have broken during this changeover. With the CSV conversion, you should be able to read any new Excel format for the foreseeable future.
精彩评论