Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Library to read Microsoft Excel files [duplicate]

I want to write a program that compares two Microsoft Excel sheets using Java.

Is there any existing library (and its documentation) that can help me get started with basic stuffs like reading all the rows and columns of the excel ?

like image 691
OneMoreError Avatar asked Jan 25 '14 13:01

OneMoreError


People also ask

Can Java read Excel files?

In Java, reading an Excel file is not similar to reading a Word file because of cells in an Excel file. JDK does not provide a direct API to read data from Excel files for which we have to toggle to a third-party library that is Apache POI.

How read Excel and Excel in Java?

we need to create a WritableWorkbook object and set the file path in Workbook. createWorkbook method. Next, we call the method createSheet to create a new sheet and set the label. Finally, we need to add cell for this we call the method addCell and pass the label object with data we want to put in the excel file.


2 Answers

Have a look at Apache POI, which is a Java API for Microsoft Documents.

And here is a tutorial on how to setup and get started with Excel files.

like image 159
Martin Seeler Avatar answered Oct 02 '22 22:10

Martin Seeler


1. Apache POI

Apache POI, a project run by the Apache Software Foundation, and previously a sub-project of the Jakarta Project, provides pure Java libraries for reading and writing files in Microsoft Office formats, such as Word, PowerPoint and Excel.

http://poi.apache.org/

2. docx4j

docx4j is a Java library for creating and manipulating Microsoft Open XML (Word docx, Powerpoint pptx, and Excel xlsx) files.

http://www.docx4java.org/trac/docx4j

like image 28
Sureshkumar Saroj Avatar answered Oct 02 '22 23:10

Sureshkumar Saroj