Sunday, November 5, 2017

Write to Excel(.XLSX) using Java Apachi POI

package MyPackage;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class WriteX {

public void writeX() throws Exception
{

File f=new File("C:/Users/Mutturaj.h/Desktop/Me.xlsx");

FileInputStream fis=new FileInputStream(f);

XSSFWorkbook wb=new XSSFWorkbook(fis);

XSSFSheet sheet=wb.getSheet("Muttu2");

XSSFRow row=sheet.createRow(6);

XSSFCell cell=row.createCell(6);

cell.setCellValue("Muttu");

FileOutputStream fos=new FileOutputStream(f);

wb.write(fos);

public static void main(String[] args) throws Exception
{

WriteX x=new WriteX();
x.writeX();

}

}

No comments:

Post a Comment