Apache POI Tutorial - How to read/write data from Excel file (Code)

For YouTube Video link Click here

package day1;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class Writing {

	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		// 1.Read Workbook    > .xls : HSSF				.xlsx : XSSF 
		XSSFWorkbook wb=new XSSFWorkbook(new FileInputStream("C:\\Users\\mprem\\OneDrive\\Desktop\\data.xlsx"));
		//2.Read SHeet
		XSSFSheet sh=wb.getSheet("Sheet1");
		String data=sh.getRow(2).getCell(1).toString();
		// 1.Reading data from cell if row & column both are there
		//2.Reading data from cell if row is there & column is not  there
		//3.Reading data from cell if row  & column both are not  there

		wb.write(new FileOutputStream("C:\\Users\\mprem\\OneDrive\\Desktop\\data.xlsx"));


  1. Thanks For Your Blog. Are you looking for the best Excel Automation Services to automate your repetitive tasks? You can effectively automate your repetitive tasks with the industry's best Excel Automation Services!


Post a Comment