All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

Reading Excel File In Java Without Poi

Last Updated : Mar 11, 2024

Reading Excel File In Java Without Poi

In this article we will show you the solution of reading excel file in java without poi, Microsoft Office documents may be read and written in both formats thanks to the Apache POI Java API. xls and.xlsx files. It includes interfaces and classes.

This same Apache POI library includes two Excel file reading implementations:

Implementation of HSSF (Horrible SpreadSheet Format): This denotes an API that works to Excel 2003 or earlier versions.

XSSF (XML SpreadSheet Format) implementations This designates an API compatible with Excel 2007 and later.

Interfaces in workbooks: The image is of an Excel workbook. Both HSSFWorkbook and XSSFWorkbook has adopted this interface.

Sheet: An Excel worksheet is represented by this interface. The main component of a workbook is a sheet, which shows a grid with cells. The Sheet interface is an extension of java.lang.Iterable.

Row: It's also an interaction that represents a spreadsheet row. Row is an extension of java.lang.Iterable. HSSFRow and XSSFRow are two concrete classes.

Cell: It serves as an interface.It's a high-level illustration of a spreadsheet row's cell. HSSFCell and XSSFCell implement the cell interface.

classes using XLS

A class called HSSFWorkbook is used to represent an XLS file.

A sheet inside an XLS file is represented by the class known as HSSFSheet.

Learning in XLSX

This class, called XSSFWorkbook, implements an XLSX file.

A sheet inside an XLSX file is represented by the class known as XSSFSheet.

A row in the sheet of an XLSX file is represented by the class XSSFRow.

A cell in a row of an XLSX file is represented by the class XSSFCell.

Step By Step Guide On Reading Excel File In Java Without Poi :-

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class TalkersCodeReadExcel
public static void main(String args[]) throws IOException
FileInputStream fis=new FileInputStream(new File("C:\\demo\\student.xls"));
HSSFbook wb=new HSSFbook(fis);
HSSFSheet sheet=wb.getSheetAt(0);
FormulaEvaluator formulaEvaluator=wb.getCreationHelper().createFormulaEvaluator();
for(Row row: sheet)
for(Cell cell: row)
System.out.print(cell.getNumericCellValue()+ "\t\t");
System.out.print(cell.getStringCellValue()+ "\t\t");
  1. In Eclipse, create a simple Java project.
  2. In the project, make a lib folder.
  3. Download file and add it to the lib folder: - commons-collections4-4.1 jar , Poi-3.17.jar , poi-ooxml-3.17.jar, Poi-Ooxml Schemas 3.17 jar, XMLBeans 2.6.0 jar
  4. Choose a class path: Pick each of the jar files indicated above by choosing Build Path > Add External JARs > Right-click the project and then click Apply and Close.
  5. Put the following logic into a class document named ReadExcelFileDemo.
  6. Make an excel file called "student.xls" and fill it with data.
  7. Save the program and run it.

Conclusion :-

Reading a excel file using Java is different from reading a word file due to the cells inside an excel file.

The JDK lacks a straightforward API for opening or closing Microsoft Word or Excel documents.

I hope this article on reading excel file in java without poi helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Dikshita

Passionate Electronics and Communication Engineering student with expertise in web development (HTML, CSS, JS,PHP, Bootstrap, React.js) and content writing. Eager problem solver and tech enthusiast, adept at creating engaging web experiences.

Follow Dikshita On Linkedin 🡪