In this program we are going create a sheet and
then by use of setRepeatingRowsAndColumns() method we create the repeating rows
or repeating column .
The package we need to import is java.io.*,java.util.* ,org.apache.poi.hssf.usermodel.HSSFSheet,org.apache.poi.hssf.usermodel.
HSSFCell,org.apache.poi.hssf.usermodel.HSSFRow, org.apache.poi.usermodel. HSSFPrintSetup and org.apache.poi.hssf.usermodel. HSSFWorkbook.
In this example we are going to create a sheet and set repeating rows and columns .We can set repeating rows and repeating columns by passing parameter values (-1 or 0).
The method used in this example shift row
setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow):
This method is define public and the return type is void .The setRepeatingRowsAndColumns is used to sets the repeating rows and columns for a sheet . This is function is include in the workbook because it creates and modifies name records which are stored at the workbook level.
To set only repeating columns we use following syntax
To set only repeating row we use following syntax
To remove all repeating rows and columns for a sheet. We use following syntax
As you see there are five parameters we are passing. These parameters are sheetIndex, startColumn, endColumn, startRow and endRow .The startColumn is 0 based start of repeating columns,the endColumn is 0 based end of repeating columns, the startRow is 0 based start of repeating rows and the endRow is 0 based end of repeating rows.
The code of the program is given below:
The output of the program is given below:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.