Javatpoint Logo
Javatpoint Logo

Apache POI Excel Document Handling

To handle the Excel (.xls) document, Apache POI provides complete API which consists of classes and methods which can be used to create excel, read and write data.

The HSSF is a pure Java implementation of excel file format. While working with excel file, first we need to create workbook by using HSSFWorkbook class.

After that to create row and cell in the sheet, API provides separate classes for each one. To create row, class and for cell class is provided.

Apache POI Workbook

It is an interface which is used to create an Excel workbook. It holds object of HSSFWorkbook class and provides methods to create, read and write into the Excel sheet.

Apache POI Workbook commonly used Methods

Method Description
CellStyle createCellStyle() It create a new Cell style and add it to the workbook's style table.
DataFormat createDataFormat() It returns the instance of DataFormat for this workbook.
Font createFont() It creates a new Font and add it to the workbook's font table.
Name createName() It creates a new defined name in this workbook.
Sheet createSheet() It creates a Sheet for this Workbook, adds it to the sheets and returns the high level representation.
Sheet createSheet(java.lang.String sheetname) It creates a new sheet for this Workbook and return the high level representation.
void write( stream)
It writes out this workbook to an Outputstream.

Workbook represents an Excel file which is created using HSSF Workbook class. Lets see a simple example where we create a workbook.

Apache POI Workbook Example


It will create an new empty Excel sheet Javatpoint.xls in current directory.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA