Big Data and Hadoop Training @$80 or Rs. 6,000 only - valid till Oct 17th Apply Now!

Excel Splits Pane Feature

Ads
 

Excel Splits Pane Feature

In this section, you will learn how to split the excel sheet using Apache POI.

In this section, you will learn how to split the excel sheet using Apache POI.

Excel Splits Pane Feature

In this section, you will learn how to split the excel sheet using Apache POI.

Sometimes, you need to view more than one copy of the sheet. This can be done using Excel Splits Pane Feature. Using this feature you can view the sheet into 4 split area.

The syntax is given below :

sheet1.createSplitPane( 2000, 2000, 0, 0, Sheet.PANE_LOWER_LEFT );

The first parameter is the x position of the split. The second parameter is the y position of the split. The last parameter indicates which pane currently has the focus.

The given below example divide the viewing area of sheet into four areas :

import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class XmlSplitPane {
public static void main(String args[]) throws IOException {
Workbook wb = new XSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet1 = wb.createSheet("new sheet");

Row row = sheet1.createRow((short) 0);
// Create a cell and put a value in it.
row.createCell(0).setCellValue(
createHelper.createRichTextString("THIS IS FREEZED ROW"));
for (int i = 1; i < 20; i++) {
row = sheet1.createRow((short) i);
row
.createCell(0)
.setCellValue(
createHelper
.createRichTextString("This is the Moving Row"));
}

sheet1.createSplitPane(2000, 2000, 0, 0, Sheet.PANE_LOWER_LEFT);

FileOutputStream fileOut = new FileOutputStream(
"xlsx/SplitWorkbook.xlsx");
wb.write(fileOut);
fileOut.close();
}
}

OUTPUT

The output is given below :

Download Source Code

Ads

Ads