In this program, we are going to create an excel using java .By going through the steps of this example we can create any number of excel pages.
To make an excel page we can use third party POI APIs. This API is provided by the Apache Jakarta (Jakarta POI - Java API To Access Microsoft Format Files
) Tomcat. You can download POI.jar
form Apache Jakarta Project it is open source.
The POI project consists APIs for manipulating various file formats based on Microsoft, OLE 2 compound Document format using pure word files using Java. We can create, read or write MS Excel file using POI.
OLE 2 Compound Document Format is based on files including most Microsoft office files as XLS and DOC.
The package we need to import is java.io.InputStream
The java.io.InputStream class is used to create file. We are creating an excel file named "rajesh.xls " The org.apache.poi.hssf.usermodel.HSSFWorkbook class is used to create an object of HSSFWorkbook, by which we will write our rajesh.xls file. This object allow us to modify the excel file.
HSSFWorkbook class extends java.lang.Object.
HSSFWorkbook class is a high level representation of a workbook.You must create
the object of HSSFBook to read and write a workbook. It is top most class for
creating new excel sheets ,doc sheets etc.
You have to follow the following step to execute this example:
The code of the program is given below:
The output of the program is given below:
Liked it! Share this Tutorial