Skip to content
Related Articles

Related Articles

Improve Article

Creating Sheets in Excel File in Java using Apache POI

  • Difficulty Level : Medium
  • Last Updated : 27 Sep, 2018

For a given Excel file (here Geeks.xlsx), it is needed to create sheets in it.


  1. Create a JAVA Maven project
  2. Add dependency in pom.xml file

  3. Create a class in javaResource folder

    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    public class CreateSheet {
        public static void main(String[] args) 
          throws FileNotFoundException, IOException
            // Creating Workbook instances
            Workbook wb = new HSSFWorkbook();
            // An output stream accepts output bytes and sends them to sink.
            OutputStream fileOut = new FileOutputStream("Geeks.xlsx");
            // Creating Sheets using sheet object
            Sheet sheet1 = wb.createSheet("Array");
            Sheet sheet2 = wb.createSheet("String");
            Sheet sheet3 = wb.createSheet("LinkedList");
            Sheet sheet4 = wb.createSheet("Tree");
            Sheet sheet5 = wb.createSheet("Dynamic Programing");
            Sheet sheet6 = wb.createSheet("Puzzles");
    System.out.println("Sheets Has been Created successfully");


Sheets Has been Created successfully

Here 6 sheets has been created in geeks.xlsx file:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :