Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Tutorials Poi Excel Splits Pane Feature

Related Tutorials


 
 

Share on Google+Share on Google+

Excel Splits Pane Feature

Advertisement
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

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 10, 2011

Related Tutorials

Discuss: Excel Splits Pane Feature  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com