In this program we are going to merge two cells of an excel sheet through java program .In this program we are going to merge two cells of an excel sheet through java program .
In this program we are going to merge two cells of an excel sheet through java program .You can merge any number of cells.
The package we need to import is
org.apache.poi. hssf. usermodel. HSSFCellStyle,
org.apache.poi.hssf.usermodel. HSSFWorkbook and
org.apache.poi.hssf.util.Region class is
used to create an object of region. This class provides a method for adding the
region. Region class is defined public and it extends the java.lang.Object
.The Region class implements java.lang.Compareble and represents a form/to row/column
In this example, we are using following key points:
This method is used to merge the region which is passed as argument into this method.
In this example, we are merging the two cells into a single cell. In this example, Region(1,(short)1,1,(short)2) represents as Region(int rowFrom, short colFrom, int rowTo, short colTo). Here the rowFrom, colFrom, rowTo and colTo is used to define the region to merge.
The code of the program is given below :
The output of the program is given below: