Java Examples - Create Blank Excel Sheet


Advertisements

Problem Description

How to create blank excel sheet using Java.

Solution

Following is the program to create blank excel sheet using Java.

import java.io.*;
import org.apache.poi.xssf.usermodel.*;

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

      //Create Blank workbook
      XSSFWorkbook workbook = new XSSFWorkbook();

      //Create file system using specific name
      FileOutputStream out = new FileOutputStream(
         new File("C:/poiexcel/createBlankWorkBook.xlsx"));

      //write operation workbook using file out object
      workbook.write(out);
      out.close();
      System.out.println("createworkbook.xlsx written successfully");
   }
}

Result

Blank Excel Sheet
java_apache_poi_excel
Advertisements