Excel.RangeFill class

表示 range 对象的背景。Represents the background of a range object.

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

Extends

属性

color

代表#RRGGBB (例如 "FFA500") 或命名的 HTML 颜色 (例如 "橙色") 的边框线条颜色的 HTML 颜色代码。HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange")

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

context

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

pattern

获取或设置区域的图案。Gets or sets the pattern of a Range. 有关详细信息,请参阅 Excel.FillPattern。See Excel.FillPattern for details. 不支持 LinearGradient 和 RectangularGradient。LinearGradient and RectangularGradient are not supported. 如果为 null 值, 则表示整个区域没有统一的模式设置。A null value indicates that the entire range doesn't have uniform pattern setting.

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

patternColor

设置表示范围模式的颜色的 HTML 颜色代码, 格式#RRGGBB (例如 "FFA500") 或命名的 HTML 颜色 (例如 "橙色")。Sets HTML color code representing the color of the Range pattern, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). 获取表示范围模式的颜色的 HTML 颜色代码, 格式#RRGGBB (例如 "FFA500")。Gets HTML color code representing the color of the Range pattern, of the form #RRGGBB (e.g. "FFA500").

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

patternTintAndShade

返回或设置一个使区域填充的图案颜色变亮或变暗的双精度数值,该值介于 -1(最暗)与 1(最亮)之间,初始颜色为 0。Returns or sets a double that lightens or darkens a pattern color for Range Fill, the value is between -1 (darkest) and 1 (brightest), with 0 for the original color. 如果模式 tintAndShades 不一致, 则将返回 null。If the pattern tintAndShades are not uniform, null will be returned.

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

tintAndShade

返回或设置一个使区域填充的颜色变亮或变暗的双精度数值,该值介于 -1(最暗)与 1(最亮)之间,初始颜色为 0。Returns or sets a double that lightens or darkens a color for Range Fill, the value is between -1 (darkest) and 1 (brightest), with 0 for the original color. 如果 tintAndShades 不是统一的, 将返回 null。If the tintAndShades are not uniform, null will be returned.

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

方法

clear()

重置区域背景。Resets the range background.

[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(propertyNamesAndPaths)

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

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

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

属性详细信息

color

代表#RRGGBB (例如 "FFA500") 或命名的 HTML 颜色 (例如 "橙色") 的边框线条颜色的 HTML 颜色代码。HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange")

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

color: string;

属性值

string

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

pattern

获取或设置区域的图案。Gets or sets the pattern of a Range. 有关详细信息,请参阅 Excel.FillPattern。See Excel.FillPattern for details. 不支持 LinearGradient 和 RectangularGradient。LinearGradient and RectangularGradient are not supported. 如果为 null 值, 则表示整个区域没有统一的模式设置。A null value indicates that the entire range doesn't have uniform pattern setting.

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

pattern: Excel.FillPattern | "None" | "Solid" | "Gray50" | "Gray75" | "Gray25" | "Horizontal" | "Vertical" | "Down" | "Up" | "Checker" | "SemiGray75" | "LightHorizontal" | "LightVertical" | "LightDown" | "LightUp" | "Grid" | "CrissCross" | "Gray16" | "Gray8" | "LinearGradient" | "RectangularGradient";

属性值

Excel.FillPattern | "None" | "Solid" | "Gray50" | "Gray75" | "Gray25" | "Horizontal" | "Vertical" | "Down" | "Up" | "Checker" | "SemiGray75" | "LightHorizontal" | "LightVertical" | "LightDown" | "LightUp" | "Grid" | "CrissCross" | "Gray16" | "Gray8" | "LinearGradient" | "RectangularGradient"

patternColor

设置表示范围模式的颜色的 HTML 颜色代码, 格式#RRGGBB (例如 "FFA500") 或命名的 HTML 颜色 (例如 "橙色")。Sets HTML color code representing the color of the Range pattern, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). 获取表示范围模式的颜色的 HTML 颜色代码, 格式#RRGGBB (例如 "FFA500")。Gets HTML color code representing the color of the Range pattern, of the form #RRGGBB (e.g. "FFA500").

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

patternColor: string;

属性值

string

patternTintAndShade

返回或设置一个使区域填充的图案颜色变亮或变暗的双精度数值,该值介于 -1(最暗)与 1(最亮)之间,初始颜色为 0。Returns or sets a double that lightens or darkens a pattern color for Range Fill, the value is between -1 (darkest) and 1 (brightest), with 0 for the original color. 如果模式 tintAndShades 不一致, 则将返回 null。If the pattern tintAndShades are not uniform, null will be returned.

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

patternTintAndShade: number;

属性值

number

tintAndShade

返回或设置一个使区域填充的颜色变亮或变暗的双精度数值,该值介于 -1(最暗)与 1(最亮)之间,初始颜色为 0。Returns or sets a double that lightens or darkens a color for Range Fill, the value is between -1 (darkest) and 1 (brightest), with 0 for the original color. 如果 tintAndShades 不是统一的, 将返回 null。If the tintAndShades are not uniform, null will be returned.

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

tintAndShade: number;

属性值

number

方法详细信息

clear()

重置区域背景。Resets the range background.

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

clear(): void;

返回

void

示例Examples

Excel.run(function (ctx) { 
    var sheetName = "Sheet1";
    var rangeAddress = "F:G";
    var worksheet = ctx.workbook.worksheets.getItem(sheetName);
    var range = worksheet.getRange(rangeAddress);
    var rangeFill = range.format.fill;
    rangeFill.clear();
    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)

将命令加入队列以加载对象的指定属性。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.RangeFillLoadOptions): Excel.RangeFill;

参数

返回

注解

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

load(option?: string | string[]): Excel.RangeFill-Where 选项是一个逗号分隔的字符串或一个字符串数组, 用于指定要加载的属性。load(option?: string | string[]): Excel.RangeFill - 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.RangeFill-Where 选项。选择是一个用逗号分隔的字符串, 用于指定要加载的属性和选项。 expand 是一个用逗号分隔的字符串, 用于指定要加载的导航属性。load(option?: { select?: string; expand?: string; }): Excel.RangeFill - 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.RangeFill-仅适用于集合类型。load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.RangeFill - 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.RangeFill;

参数

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 = "F:G";
    var worksheet = ctx.workbook.worksheets.getItem(sheetName);
    var range = worksheet.getRange(rangeAddress);
    var rangeFill = range.format.fill;
    rangeFill.load('color');
    return ctx.sync().then(function() {
        console.log(rangeFill.color);
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});
// The example below sets fill color. 
Excel.run(function (ctx) { 
    var sheetName = "Sheet1";
    var rangeAddress = "F:G";
    var range = ctx.workbook.worksheets.getItem(sheetName).getRange(rangeAddress);
    range.format.fill.color = '0000FF';
    return ctx.sync(); 
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

load(propertyNamesAndPaths)

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

load(propertyNamesAndPaths?: { select?: string; expand?: string; }): Excel.RangeFill;

参数

propertyNamesAndPaths
{ select?: string; expand?: string; }

其中, propertyNamesAndPaths 是用逗号分隔的字符串, 用于指定要加载的属性和 propertyNamesAndPaths。扩展是一个用逗号分隔的字符串, 用于指定要加载的导航属性。Where propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

返回

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.RangeFillUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Interfaces.RangeFillUpdateData

一个 JavaScript 对象, 其属性的结构 isomorphically 为在其上调用方法的对象的属性。A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

提供一个选项, 以在 properties 对象尝试设置任何只读属性时禁止显示错误。Provides an option to suppress errors if the properties object tries to set any read-only properties.

返回

void

注解

此方法具有以下附加签名:This method has the following additional signature:

set(properties: Excel.RangeFill): void

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Excel.RangeFill): void;

参数

properties
Excel.RangeFill

返回

void

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

toJSON(): Excel.Interfaces.RangeFillData;

返回