Java Read Excel xlsx file – Part 1

Excel xlsx file can be read with plain java, because xlsx files are compressed xml files in one file, like a ZIP file.
Since java has an API to work with ZIP files we can treat a xlsx file like a zip file.

In this part I’ll extract the sheet files and additionally the file with all strings (sharedstrings).
One thing you should know is that this file with strings has only unique strings in it and these are mapped to sheets with integers. So all strings in xlsx file are saved only once, no duplicates.

Refer to part 2 to see how the value in a cell can be read from sheet and sharedstrings.

Get Sheet Streams

Get Strings as List


Go to Part 2

Stuart June 24, 2013 at 8:29 am

You can look at JSpreadsheet from Independentsoft, a component for Java and Android that makes it easy to create and read Excel .xlsx files.

    metin June 24, 2013 at 8:58 am

    Thx but the point is not to use any extra libraries and I find this way to be relatively easy

ครีมหน้าใส October 17, 2014 at 3:51 am

Good post. I learn something totally new and challenging on websites I stumbleupon on a daily
basis. It will always be useful to read through articles from other authors and practice something from their web sites.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">