Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
context | The request context associated with the object. This connects the add-in's process to the Office host application's process. |
freeze |
Sets the frozen cells in the active worksheet view. The range provided corresponds to cells that will be frozen in the top- and left-most pane. |
freeze |
Freeze the first column or columns of the worksheet in place. |
freeze |
Freeze the top row or rows of the worksheet in place. |
get |
Gets a range that describes the frozen cells in the active worksheet view. The frozen range corresponds to cells that are frozen in the top- and left-most pane. |
get |
Gets a range that describes the frozen cells in the active worksheet view. The frozen range corresponds to cells that are frozen in the top- and left-most pane. If there is no frozen pane, then this method returns an object with its |
toJSON() | Overrides the JavaScript |
unfreeze() | Removes all frozen panes in the worksheet. |
The request context associated with the object. This connects the add-in's process to the Office host application's process.
context: RequestContext;
Sets the frozen cells in the active worksheet view. The range provided corresponds to cells that will be frozen in the top- and left-most pane.
freezeAt(frozenRange: Range | string): void;
Excel.Range | string
A range that represents the cells to be frozen, or null
to remove all frozen panes.
void
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
// Freeze the specified range in top-and-left-most pane of the worksheet.
sheet.freezePanes.freezeAt(sheet.getRange("H2:K5"));
await context.sync();
});
Freeze the first column or columns of the worksheet in place.
freezeColumns(count?: number): void;
number
Optional number of columns to freeze, or zero to unfreeze all columns
void
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
// Freeze the first two columns in the worksheet.
sheet.freezePanes.freezeColumns(2);
await context.sync();
});
Freeze the top row or rows of the worksheet in place.
freezeRows(count?: number): void;
number
Optional number of rows to freeze, or zero to unfreeze all rows
void
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
// Freeze the top two rows in the worksheet.
sheet.freezePanes.freezeRows(2);
await context.sync();
});
Gets a range that describes the frozen cells in the active worksheet view. The frozen range corresponds to cells that are frozen in the top- and left-most pane.
getLocation(): Excel.Range;
Gets a range that describes the frozen cells in the active worksheet view. The frozen range corresponds to cells that are frozen in the top- and left-most pane. If there is no frozen pane, then this method returns an object with its isNullObject
property set to true
. For further information, see *OrNullObject methods and properties.
getLocationOrNullObject(): Excel.Range;
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
const frozenRange = sheet.freezePanes.getLocationOrNullObject();
frozenRange.load("address");
await context.sync();
if (frozenRange.isNullObject) {
console.log(`The worksheet does not contain a frozen pane.`);
} else {
console.log(`The address of the frozen range (cells that are frozen in the top-and-left-most pane) is "${frozenRange.address}"`);
}
});
Overrides the JavaScript toJSON()
method in order to provide more useful output when an API object is passed to JSON.stringify()
. (JSON.stringify
, in turn, calls the toJSON
method of the object that's passed to it.) Whereas the original Excel.WorksheetFreezePanes
object is an API object, the toJSON
method returns a plain JavaScript object (typed as Excel.Interfaces.WorksheetFreezePanesData
) that contains shallow copies of any loaded child properties from the original object.
toJSON(): {
[key: string]: string;
};
{ [key: string]: string; }
Removes all frozen panes in the worksheet.
unfreeze(): void;
void
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/54-worksheet/worksheet-freeze-panes.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
sheet.freezePanes.unfreeze();
await context.sync();
});
Office Add-ins feedback
Office Add-ins is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in