This post shows you how to read excel file in java using POI library.
Download Here
poi-3.17.jar
poi-ooxml-3.17.jar
poi-ooxml-schemas-3.17.jar
xmlbeans-2.6.0.jar
commons-collections4-4.1.jar
Sample File: excelRead.xlsx
package com.candidjava.excel; import java.io.File; import java.io.FileInputStream; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ExcelRead { public static void main(String[] args) throws Exception { File file = new File("F:/ExcelFile/excelRead.xlsx"); FileInputStream input = new FileInputStream(file); XSSFWorkbook workbook = new XSSFWorkbook(input); XSSFSheet sheet = workbook.getSheetAt(0); Cell out=null; Iterator<Row> rowitr = sheet.iterator(); while (rowitr.hasNext()) { Row row = rowitr.next(); Iterator<Cell> cellitr = row.cellIterator(); while (cellitr.hasNext()) { Cell cell = cellitr.next(); System.out.println(cell+"\t\t\t"); } } workbook.close(); } }
OutPut
Name Age Height Kaviya 25.0 5" John 22.0 6" Reena 30.0 4"7 Raghul 24.0 4"2 Hari 18.0 4"