• Post Reply Bookmark Topic Watch Topic
  • New Topic

load data from xls and xlsx files in tables mysql  RSS feed

 
Ranch Hand
Posts: 47
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to load data from xls and xlsx files into tables in mysql using load data as we can do for csv files.

can anybody help me with the code since its not working for me for xls and xlsx files.

for csv I am using:
LOAD DATA LOCAL INFILE 'C:\\temp\\yourfile.csv' INTO TABLE database.table FIELDS TERMINATED BY ';' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (field1, field2);

but same not working for xls and xlsx files.

Thanks in advance.
 
Saloon Keeper
Posts: 4423
108
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm fairly certain that only works for CSV files, not XLS or XLSX. You'll need to convert your files to CSV first.
 
author & internet detective
Marshal
Posts: 38170
618
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim is correct. You can use Apache POI to read the Excel files and convert them into plain CSV.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!