Freeze Panes in Apache POI and Aspose.Cells

Aspose.Cells - Freeze Panes

Aspose.Cells provides a class, Workbook that represents a Microsoft Excel file. The Workbook class contains a WorksheetCollection that allows access to each worksheet in an Excel file.

A worksheet is represented by the Worksheet class. The Worksheet class provides a wide range of properties and methods for managing worksheets. To configure freeze panes, call the Worksheet class' freezePanesmethod. THe FreezePanes method takes the following parameters:

  • Row, the row index of the cell that the freeze will start from.
  • Column, the column index of the cell that the freeze will start from.
  • Frozen rows, the number of visible rows in the top pane.
  • Frozen columns, the number of visible columns in the left pane

Java

 worksheet1.freezePanes(0,2,0,2); // Freezing Columns

worksheet2.freezePanes(2,0,2,0); // Freezing Rows

Apache POI SS - HSSF XSSF - Freeze Panes

sheet.createFreezePane is available to achieve FreezePane functionality while using Apache POI SS - HSSF and XSSF

Java

 // Freeze just one row

sheet1.createFreezePane( 0, 2, 0, 2 );

// Freeze just one column

sheet2.createFreezePane( 2, 0, 2, 0 );

// Freeze the columns and rows (forget about scrolling position of the lower right quadrant).

sheet3.createFreezePane( 2, 2 );

Download Running Code

Download Sample Code