Excel.WorksheetFreezePanes class

Extends

属性

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

方法

freezeAt(frozenRange)

设置活动工作表视图中的冻结单元格。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.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

freezeColumns(count)

就地冻结工作表的第一列。Freeze the first column(s) of the worksheet in place.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

freezeRows(count)

就地冻结工作表的顶行。Freeze the top row(s) of the worksheet in place.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

getLocation()

获取用于描述活动工作表视图中的冻结单元格的区域。Gets a range that describes the frozen cells in the active worksheet view. 冻结的范围对应于顶部和最左侧窗格中冻结的单元格。The frozen range is corresponds to cells that are frozen in the top- and left-most pane.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

getLocationOrNullObject()

获取用于描述活动工作表视图中的冻结单元格的区域。Gets a range that describes the frozen cells in the active worksheet view. 冻结的范围对应于顶部和最左侧窗格中冻结的单元格。The frozen range is corresponds to cells that are frozen in the top- and left-most pane. 如果没有冻结的窗格, 则返回 null 对象。If there is no frozen pane, returns a null object.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始 WorksheetFreezePanes 对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.WorksheetFreezePanesData, in turn, calls the toJSON method of the object that is 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.

unfreeze()

移除工作表中的所有冻结窗格。Removes all frozen panes in the worksheet.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

属性详细信息

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

context: RequestContext;

属性值

RequestContext

方法详细信息

freezeAt(frozenRange)

设置活动工作表视图中的冻结单元格。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.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

freezeAt(frozenRange: Range | string): void;

参数

frozenRange
Range | string

一个代表要冻结的单元格的区域, 或为 null 以删除所有冻结的窗格。A range that represents the cells to be frozen, or null to remove all frozen panes.

返回

void

示例Examples

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();
});

freezeColumns(count)

就地冻结工作表的第一列。Freeze the first column(s) of the worksheet in place.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

freezeColumns(count?: number): void;

参数

count
number

可选的要冻结的列数, 或为零取消对所有列的冻结Optional number of columns to freeze, or zero to unfreeze all columns

返回

void

示例Examples

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();
});

freezeRows(count)

就地冻结工作表的顶行。Freeze the top row(s) of the worksheet in place.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

freezeRows(count?: number): void;

参数

count
number

可选的要冻结的行数, 或零取消对所有行的冻结Optional number of rows to freeze, or zero to unfreeze all rows

返回

void

示例Examples

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();
});

getLocation()

获取用于描述活动工作表视图中的冻结单元格的区域。Gets a range that describes the frozen cells in the active worksheet view. 冻结的范围对应于顶部和最左侧窗格中冻结的单元格。The frozen range is corresponds to cells that are frozen in the top- and left-most pane.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

getLocation(): Excel.Range;

返回

getLocationOrNullObject()

获取用于描述活动工作表视图中的冻结单元格的区域。Gets a range that describes the frozen cells in the active worksheet view. 冻结的范围对应于顶部和最左侧窗格中冻结的单元格。The frozen range is corresponds to cells that are frozen in the top- and left-most pane. 如果没有冻结的窗格, 则返回 null 对象。If there is no frozen pane, returns a null object.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

getLocationOrNullObject(): Excel.Range;

返回

示例Examples

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}"`);
    }
});

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始 WorksheetFreezePanes 对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.WorksheetFreezePanesData, in turn, calls the toJSON method of the object that is 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; }

unfreeze()

移除工作表中的所有冻结窗格。Removes all frozen panes in the worksheet.

[API 集: ExcelApi 1.7][ API set: ExcelApi 1.7 ]

unfreeze(): void;

返回

void

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    sheet.freezePanes.unfreeze();

    await context.sync();
});