Share on Google+Share on Google+

Excel Freeze Pane Feature

In this section, you will learn about freezing row of excel document using Apache POI library.

Excel Freeze Pane Feature

In this section, you will learn about freezing row of excel document using Apache POI library.

Sometimes when you scroll down too far, we lost the heading at top. Due to this, we feel difficulty to relate which cell belongs to which heading. The solution of this problem is Freeze Pane which freezes the the row you want to retain at it's place.

Given below code will freezes the top row and all other row can scroll up or scroll down :


import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class XLfreezePanes {
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.
createHelper.createRichTextString("THIS IS FREEZED ROW"));
for (int i = 1; i < 20; i++) {
row = sheet1.createRow((short) i);
.createRichTextString("This is the Moving Row"));

// Freeze just one row
sheet1.createFreezePane(0, 1, 0, 1);

FileOutputStream fileOut = new FileOutputStream(

In the function createFreezePane , the first two parameters are the columns and rows you wish to split by. The second two parameters indicate the cells that are visible in the bottom right quadrant.


In the below example, row 1freezes and all other can scroll up or down :

Download Source Code


Posted on: August 10, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Discuss: Excel Freeze Pane Feature  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image