GuidesUniver SheetsFeaturesCoreFreeze

Freeze 0.3.0+

The FWorksheet class provides several methods to manage the frozen state of rows and columns in a worksheet. These methods allow you to set, get, and cancel frozen panes.

Facade API

Sets the number of frozen columns

const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
 
worksheet.setFrozenColumns(2);

Sets the number of frozen rows

const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
 
worksheet.setFrozenRows(3);

Getting freeze state

const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
 
const freezeState = worksheet.getFreeze();
console.log('Current freeze state: ', freezeState);

Gets the number of frozen columns

const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
 
const frozenColumns = worksheet.getFrozenColumns();
console.log(`Frozen columns: ${frozenColumns}`);

Gets the number of frozen rows

const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
 
const frozenRows = worksheet.getFrozenRows();
console.log(`Frozen rows: ${frozenRows}`);

Canceling Freeze

const worksheet = univerAPI.getActiveWorkbook().getActiveSheet();
 
// Cancel all freezing
worksheet.cancelFreeze();
 
// Verify that freezing has been canceled
console.log('Frozen columns after cancel: ', worksheet.getFrozenColumns());
console.log('Frozen rows after cancel: ', worksheet.getFrozenRows());