Opening Existing Excel sheet in Java using Apache POI
Apache POI is a powerful API by which one can read, write and modify any Microsoft document like powerpoint, world, or excel.
Apache POI have different classes and method to work upon different MS Office Document.
POIFS
It’s Stand for “Poor Obfuscation Implementation File System”. This component is the basic factor of all other POI elements. It is used to read different files explicitly.
HSSF
It’s Stand for “Horrible Spreadsheet Format”. It is used to read and write xls format of MS-Excel files.
XSSF
It’s Stand for “XML Spreadsheet Format”. It is used for xlsx file format of MS-Excel.
HPSF
It’s Stand for “Horrible Property Set Format”. It is used to extract property sets of the MS-Office files.
HWPF
It’s Stand for “Horrible Word Processor Format”. It is used to read and write doc extension files of MS-Word.
XWPF
It’s Stand for “XML Word Processor Format”. It is used to read and write docx extension files of MS-Word.
HSLF
It’s Stand for “Horrible Slide Layout Format”. It is used for read, create, and edit PowerPoint presentations.
HDGF
It’s Stand for “Horrible Diagram Format”. It contains classes and methods for MS-Visio binary files.
HPBF
It’s Stand for “Horrible PuBlisher Format”. It is used to read and write MS-Publisher files.
Steps to Open Existing Excel Sheet in Java, in eclipse
- Create a JAVA Maven project
- Add dependency in pom.xml file
<dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>3.12</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>3.12</version></dependency>chevron_rightfilter_none - Create a class in javaResource folder
importjava.io.File;importjava.io.FileInputStream;importorg.apache.poi.xssf.usermodel.XSSFWorkbook;publicclassGFG {publicstaticvoidmain(String args[])throwsException{// Create a file object// for the path of existing Excel file// Give the path of the file as parameter// from where file is to be readFile file =newFile("Geeks.xlsx");// Create a FileInputStream object// for getting the information of the fileFileInputStream fip =newFileInputStream(file);// Getting the workbook instance for XLSX fileXSSFWorkbook workbook =newXSSFWorkbook(fIP);// Ensure if file exist or notif(file.isFile() && file.exists()) {System.out.println("Geeks.xlsx open");}else{System.out.println("Geeks.xlsx either not exist"+" or can't open");}}}chevron_rightfilter_none - Run the code as java aplication
- Finish
Output:
Geeks.xlsx open
File location in eclipse

Recommended Posts:
- Creating Sheets in Excel File in Java using Apache POI
- Creating a Cell at specific position in Excel file using Java
- Apache POI | Getting Started
- Apache JMeter - An Introduction
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java Deprecated API Scanner tool (jdepscan) in Java 9 with Examples
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.function.BiPredicate interface in Java with Examples
- Java.util.concurrent.Phaser class in Java with Examples
- Java.util.function.IntPredicate interface in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

