1

I am using opencsv jar file and via this I want to read .xlsx file, so can any one help me how to do this. I have explored it but most of the content I have found via Apache poi, but I want to read it with opencsv.

Thanks in advance.

irfanmcsd
  • 6,533
  • 7
  • 38
  • 53
user2092132
  • 137
  • 2
  • 3
  • 13
  • As the name of the jar file tells that it is used for CSV files. So i don't understand why do you want to eat your soup with chopsticks(opencsv) when you already have spoon(poi)? Is there any special requirement? – Mrunal Gosar Sep 23 '14 at 04:02
  • @MrunalGosar ok buddy then tell me is there any jar which helps to open a csv or excel or any kind of file because all the time requirement are different and we want that our code was same and open both formate of file. – user2092132 Sep 23 '14 at 16:18
  • they are completely different kinds of files. As is .xls, by the way. POI is going to be your best start, and possibly only real solution for the xlsx files. – Garr Godfrey Sep 23 '14 at 21:52
  • @GarrGodfrey Ok but can you please let me know how can I do that thing? (Different format of file with one Jar) – user2092132 Sep 24 '14 at 03:11
  • that's not going to happen unless you make your own. You need to detect what file type it is, and then call the appropriate library to parse it. Then, you may need to massage one type into another. An xlsx is a complicated format, with formulas, macros and all kinds of things, so simply "reading" it depends a lot on what you are going to do with it. – Garr Godfrey Sep 24 '14 at 06:20
  • my suggestion: use POI to convert to a csv, then use opencsv – Garr Godfrey Sep 24 '14 at 06:21
  • http://stackoverflow.com/questions/17345696/convert-xlsx-to-csv-with-apache-poi-api – Garr Godfrey Sep 24 '14 at 06:22

1 Answers1

1

convert the xlsx to a csv here: https://cloudconvert.org/csv-to-xlsx

Then you can use opencsv.

Garr Godfrey
  • 8,257
  • 2
  • 25
  • 23