Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing Excel file without Apache POI

I know that we can use Apache POI to parse an Excel file and get data. But I heard of a strange thing that excel file can be passed in a similar way we parse CSV (Like just read the file from file Stream and separate each column value with a "comma" separator). When we parse Excel we have to use tab as a delimiter. Is it possible? If yes then why Apache has come up with such a complicated framework. I am puzzled. Can someone help me?

like image 833
Rengasami Ramanujam Avatar asked Apr 20 '12 15:04

Rengasami Ramanujam


People also ask

How do I read data from an Excel spreadsheet?

To read data from Excel cells, use the Excel runtime object. In some advanced cases, for instance, when you work with ranges of cells in Excel files, you can use the Excel. Application COM object.

Does Apache POI require Excel?

Save this answer. Show activity on this post. Yes, it works without Excel application in your VM.


2 Answers

CSV is a text format, so it can be parsed using the delimiters. Old Excel is a binary and proprietary format so it needs clever decoding. The new Excel format is zipped XMLs, but one should also understand the structure of this document before it could be transformed into something as simple as reading cells one by one. So the answer to your question is no, you'll need to use Apache POI, and also - there's nothing wrong with that.

As a side note, on the path to become a good developer you will need to learn to do a bit of your own research before looking for help. Get your hands dirty is the best way to learn things.

like image 197
maksimov Avatar answered Oct 05 '22 23:10

maksimov


You've probably confused what you've heard, or the person telling you was confused.

Some parts of Excel files can be stored (somewhat) as CSV files as the tabular data structure fits well within a CSV file format. However, if you save in CSV format then you just get plain text in each cell - you lose all formatting information, any graphs, multiple worksheets and so on.

The native XLS excel format is what Apache POI works with, and so can handle everything in excel, not just restrictive plain text in certain cells. CSV files have their uses but they're definitely not a straight replacement for normal Excel files.

like image 23
Michael Berry Avatar answered Oct 05 '22 22:10

Michael Berry