Reading excelFile Data using JAVA POI

JAVA POI Jars For MSOffice Applications read and writing that files. Click Here to download POI Jars Reading Excel File and converting to java objects
public void readExcelFile(String pathName) {
		try {
                         //Reading excel file using FileInputStream
			FileInputStream fis = new FileInputStream(new File(pathName));
			//Here we get excelWorkBook object for that excel file
			XSSFWorkbook excelWorkbook =  new XSSFWorkbook(fis);
			//Here we get excelWorkSheet object  for that excelWorkBook object
			XSSFSheet excelSheet = excelWorkbook.getSheetAt(0);
			//Here we get Iterate excelWorkSheet  object 
			Iterator<Row> rowIterator = excelSheet.iterator();
			int cellIndexForSupplier = getColumnIndexForSupplier(rowIterator.next());
			while (rowIterator.hasNext()) {
                               //Here you will get each row in an excelsheet
				Row row = (Row) rowIterator.next();
				
				
			}
			excelWorkbook.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
Getting Specified Cell Value From Excel Sheet
	//Getting specified cell using row object
	private void getSpecifiedCellInRow(Row row) {
		
	//Using Cell interface in org.apache.poi.ss.usermodel.Cell to read all cells in a single row
		for(Cell cell : row) 
		{
			String val = cell.getStringCellValue();
			
		}
	}

Comments