Excel.RangeBorderCollection class

表示构成区域边框的 Border 对象。Represents the border objects that make up the range border.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

Extends

属性

context

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

count

集合中的 border 对象数量。Number of border objects in the collection. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

items

获取此集合中已加载的子项。Gets the loaded child items in this collection.

tintAndShade

返回或设置一个使区域边框的颜色变亮或变暗的双精度数值,该值介于 -1(最暗)与 1(最亮)之间,初始颜色为 0。Returns or sets a double that lightens or darkens a color for Range Borders, the value is between -1 (darkest) and 1 (brightest), with 0 for the original color. 空值表示整个边框集合没有统一的 tintAndShade 设置。A null value indicates that the entire border collections don't have uniform tintAndShade setting.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

方法

getItem(index)

使用其名称获取 border 对象Gets a border object using its name.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getItem(indexString)

使用其名称获取 border 对象Gets a border object using its name.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getItemAt(index)

使用其索引获取 border 对象Gets a border object using its index.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(option)
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给它的对象的方法。尽管原始Excel.RangeBorderCollection对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.RangeBorderCollectionData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.RangeBorderCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.RangeBorderCollectionData), 其中包含集合的项中所有加载属性的浅表副本的 "items" 数组。) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

属性详细信息

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

count

集合中的 border 对象数量。Number of border objects in the collection. 只读。Read-only.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

readonly count: number;

属性值

number

items

获取此集合中已加载的子项。Gets the loaded child items in this collection.

readonly items: Excel.RangeBorder[];

属性值

Excel.RangeBorder[]

tintAndShade

返回或设置一个使区域边框的颜色变亮或变暗的双精度数值,该值介于 -1(最暗)与 1(最亮)之间,初始颜色为 0。Returns or sets a double that lightens or darkens a color for Range Borders, the value is between -1 (darkest) and 1 (brightest), with 0 for the original color. 空值表示整个边框集合没有统一的 tintAndShade 设置。A null value indicates that the entire border collections don't have uniform tintAndShade setting.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

tintAndShade: number;

属性值

number

方法详细信息

getItem(index)

使用其名称获取 border 对象Gets a border object using its name.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getItem(index: Excel.BorderIndex): Excel.RangeBorder;

参数

index
Excel.BorderIndex

要检索的 border 对象的索引值。Index value of the border object to be retrieved. 有关详细信息, 请参阅 BorderIndex。See Excel.BorderIndex for details.

返回

示例Examples

Excel.run(function (ctx) { 
    var sheetName = "Sheet1";
    var rangeAddress = "A1:F8";
    var worksheet = ctx.workbook.worksheets.getItem(sheetName);
    var range = worksheet.getRange(rangeAddress);
    var borderName = 'EdgeTop';
    var border = range.format.borders.getItem(borderName);
    border.load('style');
    return ctx.sync().then(function() {
            console.log(border.style);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

getItem(indexString)

使用其名称获取 border 对象Gets a border object using its name.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getItem(indexString: "EdgeTop" | "EdgeBottom" | "EdgeLeft" | "EdgeRight" | "InsideVertical" | "InsideHorizontal" | "DiagonalDown" | "DiagonalUp"): Excel.RangeBorder;

参数

indexString
"EdgeTop" | "EdgeBottom" | "EdgeLeft" | "EdgeRight" | "InsideVertical" | "InsideHorizontal" | "DiagonalDown" | "DiagonalUp"

要检索的 border 对象的索引值。Index value of the border object to be retrieved. 有关详细信息, 请参阅 BorderIndex。See Excel.BorderIndex for details.

返回

getItemAt(index)

使用其索引获取 border 对象Gets a border object using its index.

[API 集: ExcelApi 1.1][ API set: ExcelApi 1.1 ]

getItemAt(index: number): Excel.RangeBorder;

参数

index
number

要检索的对象的索引值。Index value of the object to be retrieved. 从零开始编制索引。Zero-indexed.

返回

示例Examples

Excel.run(function (ctx) { 
    var sheetName = "Sheet1";
    var rangeAddress = "A1:F8";
    var worksheet = ctx.workbook.worksheets.getItem(sheetName);
    var range = worksheet.getRange(rangeAddress);
    var border = range.format.borders.getItemAt(0);
    border.load('sideIndex');
    return ctx.sync().then(function() {
        console.log(border.sideIndex);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(option?: Excel.Interfaces.RangeBorderCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.RangeBorderCollection;

参数

option
Excel.Interfaces.RangeBorderCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions

返回

注解

除了此签名之外, 此方法还具有以下签名:In addition to this signature, this method has the following signatures:

load(option?: string | string[]): Excel.RangeBorderCollection-Where 选项是一个逗号分隔的字符串或一个字符串数组, 用于指定要加载的属性。load(option?: string | string[]): Excel.RangeBorderCollection - Where option is a comma-delimited string or an array of strings that specify the properties to load.

load(option?: { select?: string; expand?: string; }): Excel.RangeBorderCollection-Where 选项。选择是一个用逗号分隔的字符串, 用于指定要加载的属性和选项。 expand 是一个用逗号分隔的字符串, 用于指定要加载的导航属性。load(option?: { select?: string; expand?: string; }): Excel.RangeBorderCollection - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.RangeBorderCollection-仅适用于集合类型。load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.RangeBorderCollection - Only available on collection types. 它类似于前面的签名。It is similar to the preceding signature. Top 指定结果中可包含的集合项的最大数量。Option.top specifies the maximum number of collection items that can be included in the result. 选项。 skip 指定要跳过且不包含在结果中的项目数。Option.skip specifies the number of items that are to be skipped and not included in the result. 如果指定了 top 选项, 则在跳过指定数目的项目后将启动结果集。If option.top is specified, the result set will start after skipping the specified number of items.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Excel.RangeBorderCollection;

参数

propertyNames
string | string[]

一个以逗号分隔的字符串或字符串数组, 用于指定要加载的属性。A comma-delimited string or an array of strings that specify the properties to load.

返回

示例Examples

Excel.run(function (ctx) { 
    var sheetName = "Sheet1";
    var rangeAddress = "A1:F8";
    var worksheet = ctx.workbook.worksheets.getItem(sheetName);
    var range = worksheet.getRange(rangeAddress);
    var borders = range.format.borders;
    border.load('items');
    return ctx.sync().then(function() {
        console.log(borders.count);
        for (var i = 0; i < borders.items.length; i++)
        {
            console.log(borders.items[i].sideIndex);
        }
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});
// The example below adds grid border around the range.
Excel.run(function (ctx) { 
    var sheetName = "Sheet1";
    var rangeAddress = "A1:F8";
    var range = ctx.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
    range.format.borders.getItem('InsideHorizontal').style = 'Continuous';
    range.format.borders.getItem('InsideVertical').style = 'Continuous';
    range.format.borders.getItem('EdgeBottom').style = 'Continuous';
    range.format.borders.getItem('EdgeLeft').style = 'Continuous';
    range.format.borders.getItem('EdgeRight').style = 'Continuous';
    range.format.borders.getItem('EdgeTop').style = 'Continuous';
    return ctx.sync(); 
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

load(option)

load(option?: OfficeExtension.LoadOption): Excel.RangeBorderCollection;

参数

返回

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给它的对象的方法。尽管原始Excel.RangeBorderCollection对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.RangeBorderCollectionData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.RangeBorderCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.RangeBorderCollectionData), 其中包含集合的项中所有加载属性的浅表副本的 "items" 数组。) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

toJSON(): Excel.Interfaces.RangeBorderCollectionData;

返回