Creating Sheets in Excel File in Java using Apache POI
Apache POI is an open-source java library to create and manipulate various file formats based on Microsoft Office. Using POI, one should be able to perform create, modify and display/read operations on the following file formats. For Example, java doesn’t provide built-in support for working with excel files, so we need to look for open-source APIs for the job.
Apache POI provides Java API for manipulating various file formats based on the Office Open XML (OOXML) standard and OLE2 standard from Microsoft. Apache POI releases are available under the Apache License (V2.0).
Before we move ahead it is suggested geeks you must be well versed with how to read files in the Apache POI library. it does include fundamental interfaces such as Workbook, Sheet, Row, and Cell. For a given Excel file say here it be ‘Geeks.xlsx’, it is needed to create sheets in it then do follow these below generic steps as listed below:
Step 1: Create a Java Maven project
Step 2: Add dependency in the pom.xml file. It is as shown below in the media file.
Step 3: Create a class in the ‘javaResource’ Folder.
Output: On console
Sheets Has been Created successfully Total Number of Sheets: 6
Output: Changes inside the Excel file are depicted in below visual aid provided.
Here 6 sheets will be created in the Excel file passed in the above program that is ‘geeks.xlsx‘ as shown in the below media provided.