Excel.ConditionalFormat class

一个封装条件格式的范围、格式、规则和其他属性的对象。An object encapsulating a conditional format's range, format, rule, and other properties.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

Extends

属性

cellValue

如果当前条件格式为 CellValue 类型, 则返回单元格值条件格式属性。Returns the cell value conditional format properties if the current conditional format is a CellValue type. 例如, 设置5到10之间的所有单元格的格式。For example to format all cells between 5 and 10. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

cellValueOrNullObject

如果当前条件格式为 CellValue 类型, 则返回单元格值条件格式属性。Returns the cell value conditional format properties if the current conditional format is a CellValue type. 例如, 设置5到10之间的所有单元格的格式。For example to format all cells between 5 and 10. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

colorScale

如果当前条件格式为色阶类型, 则返回色阶条件格式属性。Returns the ColorScale conditional format properties if the current conditional format is an ColorScale type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

colorScaleOrNullObject

如果当前条件格式为色阶类型, 则返回色阶条件格式属性。Returns the ColorScale conditional format properties if the current conditional format is an ColorScale type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

context

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

custom

如果当前条件格式为自定义类型, 则返回自定义条件格式属性。Returns the custom conditional format properties if the current conditional format is a custom type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

customOrNullObject

如果当前条件格式为自定义类型, 则返回自定义条件格式属性。Returns the custom conditional format properties if the current conditional format is a custom type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

dataBar

如果当前条件格式为数据栏, 则返回数据条属性。Returns the data bar properties if the current conditional format is a data bar. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

dataBarOrNullObject

如果当前条件格式为数据栏, 则返回数据条属性。Returns the data bar properties if the current conditional format is a data bar. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

iconSet

如果当前条件格式为 IconSet 类型, 则返回 IconSet 条件格式属性。Returns the IconSet conditional format properties if the current conditional format is an IconSet type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

iconSetOrNullObject

如果当前条件格式为 IconSet 类型, 则返回 IconSet 条件格式属性。Returns the IconSet conditional format properties if the current conditional format is an IconSet type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

id

当前 ConditionalFormatCollection 内的条件格式的优先级。The Priority of the Conditional Format within the current ConditionalFormatCollection. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

preset

返回预设条件的条件格式。Returns the preset criteria conditional format. 有关更多详细信息, 请参阅 PresetCriteriaConditionalFormat。See Excel.PresetCriteriaConditionalFormat for more details.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

presetOrNullObject

返回预设条件的条件格式。Returns the preset criteria conditional format. 有关更多详细信息, 请参阅 PresetCriteriaConditionalFormat。See Excel.PresetCriteriaConditionalFormat for more details.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

priority

条件格式集合中当前存在此条件格式的优先级 (或索引)。The priority (or index) within the conditional format collection that this conditional format currently exists in. 更改此设置还会更改其他条件格式的优先级, 以允许进行连续的优先级顺序。Changing this also changes other conditional formats' priorities, to allow for a contiguous priority order. 使用负优先级从后开始。Use a negative priority to begin from the back. 优先级大于界限将获取并设置为最大值 (如果为负, 则为最小值) 优先级。Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. 另请注意, 如果您更改优先级, 则必须在该新的优先级位置重新获取该对象的新副本 (如果要对其进行进一步的更改)。Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

stopIfTrue

如果满足此条件格式的条件,则不会有任何低优先级格式应在此单元格上生效。If the conditions of this conditional format are met, no lower-priority formats shall take effect on that cell. 数值、icon sets 和 colorscales 中的 Null, 因为没有针对这些项的 StopIfTrue 的概念Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

textComparison

如果当前条件格式是文本类型, 则返回特定的文本条件格式属性。Returns the specific text conditional format properties if the current conditional format is a text type. 例如, 设置与单词 "Text" 相匹配的单元格的格式。For example to format cells matching the word "Text". 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

textComparisonOrNullObject

如果当前条件格式是文本类型, 则返回特定的文本条件格式属性。Returns the specific text conditional format properties if the current conditional format is a text type. 例如, 设置与单词 "Text" 相匹配的单元格的格式。For example to format cells matching the word "Text". 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

topBottom

如果当前条件格式为 TopBottom 类型, 则返回 Top/底端条件格式属性。Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. 例如, 设置前 10% 或前10个项目的格式。For example to format the top 10% or bottom 10 items. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

topBottomOrNullObject

如果当前条件格式为 TopBottom 类型, 则返回 Top/底端条件格式属性。Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. 例如, 设置前 10% 或前10个项目的格式。For example to format the top 10% or bottom 10 items. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

type

一种条件格式。A type of conditional format. 一次只能设置一个。Only one can be set at a time. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

方法

delete()

删除此条件格式。Deletes this conditional format.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

getRange()

返回应用条件格式的范围。Returns the range the conditonal format is applied to. 如果将条件格式应用于多个区域, 则会引发错误。Throws an error if the conditional format is applied to multiple ranges. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

getRangeOrNullObject()

返回条件格式应用于的区域; 或者, 如果将条件格式应用于多个区域, 则返回 null 对象。Returns the range the conditonal format is applied to, or a null object if the conditional format is applied to multiple ranges. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

getRanges()

返回将为其应用条件格式的 RangeAreas,它包含一个或多个矩形区域。Returns the RangeAreas, comprising one or more rectangular ranges, the conditonal format is applied to. 只读。Read-only.

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

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

属性详细信息

cellValue

如果当前条件格式为 CellValue 类型, 则返回单元格值条件格式属性。Returns the cell value conditional format properties if the current conditional format is a CellValue type. 例如, 设置5到10之间的所有单元格的格式。For example to format all cells between 5 and 10. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly cellValue: Excel.CellValueConditionalFormat;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B21:E23");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.cellValue);
    conditionalFormat.cellValue.format.font.color = "red";
    conditionalFormat.cellValue.rule = { formula1: "=0", operator: "LessThan" };

    await context.sync();
});

cellValueOrNullObject

如果当前条件格式为 CellValue 类型, 则返回单元格值条件格式属性。Returns the cell value conditional format properties if the current conditional format is a CellValue type. 例如, 设置5到10之间的所有单元格的格式。For example to format all cells between 5 and 10. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly cellValueOrNullObject: Excel.CellValueConditionalFormat;

属性值

colorScale

如果当前条件格式为色阶类型, 则返回色阶条件格式属性。Returns the ColorScale conditional format properties if the current conditional format is an ColorScale type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly colorScale: Excel.ColorScaleConditionalFormat;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B2:M5");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.colorScale);
    const criteria = {
        minimum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.lowestValue, color: "blue" },
        midpoint: { formula: "50", type: Excel.ConditionalFormatColorCriterionType.percent, color: "yellow" },
        maximum: { formula: null, type: Excel.ConditionalFormatColorCriterionType.highestValue, color: "red" }
    };
    conditionalFormat.colorScale.criteria = criteria;

    await context.sync();
});

colorScaleOrNullObject

如果当前条件格式为色阶类型, 则返回色阶条件格式属性。Returns the ColorScale conditional format properties if the current conditional format is an ColorScale type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly colorScaleOrNullObject: Excel.ColorScaleConditionalFormat;

属性值

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

custom

如果当前条件格式为自定义类型, 则返回自定义条件格式属性。Returns the custom conditional format properties if the current conditional format is a custom type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly custom: Excel.CustomConditionalFormat;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B8:E13");
    const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom);
    conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)';
    conditionalFormat.custom.format.font.color = "green";

    await context.sync();
});

customOrNullObject

如果当前条件格式为自定义类型, 则返回自定义条件格式属性。Returns the custom conditional format properties if the current conditional format is a custom type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly customOrNullObject: Excel.CustomConditionalFormat;

属性值

dataBar

如果当前条件格式为数据栏, 则返回数据条属性。Returns the data bar properties if the current conditional format is a data bar. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly dataBar: Excel.DataBarConditionalFormat;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B8:E13");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.dataBar);
    conditionalFormat.dataBar.barDirection = Excel.ConditionalDataBarDirection.leftToRight;

    await context.sync();
});

dataBarOrNullObject

如果当前条件格式为数据栏, 则返回数据条属性。Returns the data bar properties if the current conditional format is a data bar. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly dataBarOrNullObject: Excel.DataBarConditionalFormat;

属性值

iconSet

如果当前条件格式为 IconSet 类型, 则返回 IconSet 条件格式属性。Returns the IconSet conditional format properties if the current conditional format is an IconSet type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly iconSet: Excel.IconSetConditionalFormat;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B8:E13");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.iconSet);
    const iconSetCF = conditionalFormat.iconSet;
    iconSetCF.style = Excel.IconSet.threeTriangles;

    /*
        The iconSetCF.criteria array is automatically prepopulated with
        criterion elements whose properties have been given default settings.
        You can't write to each property of a criterion directly. Instead,
        replace the whole criteria object.

        With a "three*" icon set style, such as "threeTriangles", the third
        element in the criteria array (criteria[2]) defines the "top" icon;
        e.g., a green triangle. The second (criteria[1]) defines the "middle"
        icon, The first (criteria[0]) defines the "low" icon, but it
        can often be left empty as this method does below, because every
        cell that does not match the other two criteria always gets the low
        icon.            
    */
    iconSetCF.criteria = [
        {} as any,
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=700"
        },
        {
            type: Excel.ConditionalFormatIconRuleType.number,
            operator: Excel.ConditionalIconCriterionOperator.greaterThanOrEqual,
            formula: "=1000",
        }
    ];

    await context.sync();
});

iconSetOrNullObject

如果当前条件格式为 IconSet 类型, 则返回 IconSet 条件格式属性。Returns the IconSet conditional format properties if the current conditional format is an IconSet type. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly iconSetOrNullObject: Excel.IconSetConditionalFormat;

属性值

id

当前 ConditionalFormatCollection 内的条件格式的优先级。The Priority of the Conditional Format within the current ConditionalFormatCollection. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly id: string;

属性值

string

preset

返回预设条件的条件格式。Returns the preset criteria conditional format. 有关更多详细信息, 请参阅 PresetCriteriaConditionalFormat。See Excel.PresetCriteriaConditionalFormat for more details.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly preset: Excel.PresetCriteriaConditionalFormat;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B2:M5");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.presetCriteria);
    conditionalFormat.preset.format.font.color = "white";
    conditionalFormat.preset.rule = { criterion: Excel.ConditionalFormatPresetCriterion.oneStdDevAboveAverage };

    await context.sync();
});

presetOrNullObject

返回预设条件的条件格式。Returns the preset criteria conditional format. 有关更多详细信息, 请参阅 PresetCriteriaConditionalFormat。See Excel.PresetCriteriaConditionalFormat for more details.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly presetOrNullObject: Excel.PresetCriteriaConditionalFormat;

属性值

priority

条件格式集合中当前存在此条件格式的优先级 (或索引)。The priority (or index) within the conditional format collection that this conditional format currently exists in. 更改此设置还会更改其他条件格式的优先级, 以允许进行连续的优先级顺序。Changing this also changes other conditional formats' priorities, to allow for a contiguous priority order. 使用负优先级从后开始。Use a negative priority to begin from the back. 优先级大于界限将获取并设置为最大值 (如果为负, 则为最小值) 优先级。Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. 另请注意, 如果您更改优先级, 则必须在该新的优先级位置重新获取该对象的新副本 (如果要对其进行进一步的更改)。Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

priority: number;

属性值

number

stopIfTrue

如果满足此条件格式的条件,则不会有任何低优先级格式应在此单元格上生效。If the conditions of this conditional format are met, no lower-priority formats shall take effect on that cell. 数值、icon sets 和 colorscales 中的 Null, 因为没有针对这些项的 StopIfTrue 的概念Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

stopIfTrue: boolean;

属性值

boolean

textComparison

如果当前条件格式是文本类型, 则返回特定的文本条件格式属性。Returns the specific text conditional format properties if the current conditional format is a text type. 例如, 设置与单词 "Text" 相匹配的单元格的格式。For example to format cells matching the word "Text". 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly textComparison: Excel.TextConditionalFormat;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B16:D18");
    const conditionalFormat = range.conditionalFormats
        .add(Excel.ConditionalFormatType.containsText);
    conditionalFormat.textComparison.format.font.color = "red";
    conditionalFormat.textComparison.rule = { operator: Excel.ConditionalTextOperator.contains, text: "Delayed" };

    await context.sync();
});

textComparisonOrNullObject

如果当前条件格式是文本类型, 则返回特定的文本条件格式属性。Returns the specific text conditional format properties if the current conditional format is a text type. 例如, 设置与单词 "Text" 相匹配的单元格的格式。For example to format cells matching the word "Text". 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly textComparisonOrNullObject: Excel.TextConditionalFormat;

属性值

topBottom

如果当前条件格式为 TopBottom 类型, 则返回 Top/底端条件格式属性。Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. 例如, 设置前 10% 或前10个项目的格式。For example to format the top 10% or bottom 10 items. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly topBottom: Excel.TopBottomConditionalFormat;

属性值

topBottomOrNullObject

如果当前条件格式为 TopBottom 类型, 则返回 Top/底端条件格式属性。Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. 例如, 设置前 10% 或前10个项目的格式。For example to format the top 10% or bottom 10 items. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly topBottomOrNullObject: Excel.TopBottomConditionalFormat;

属性值

type

一种条件格式。A type of conditional format. 一次只能设置一个。Only one can be set at a time. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

readonly type: Excel.ConditionalFormatType | "Custom" | "DataBar" | "ColorScale" | "IconSet" | "TopBottom" | "PresetCriteria" | "ContainsText" | "CellValue";

属性值

Excel.ConditionalFormatType | "Custom" | "DataBar" | "ColorScale" | "IconSet" | "TopBottom" | "PresetCriteria" | "ContainsText" | "CellValue"

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const worksheetRange = sheet.getRange();
    worksheetRange.conditionalFormats.load("type");

    await context.sync();

    let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = [];
    worksheetRange.conditionalFormats.items.forEach(item => {
        cfRangePairs.push({
            cf: item,
            range: item.getRange().load("address")
        });
    });

    await context.sync();

    if (cfRangePairs.length > 0) {
        cfRangePairs.forEach(item => {
            console.log(item.cf.type);
        });
    } else {
        console.log("No conditional formats applied.");
    }
});

方法详细信息

delete()

删除此条件格式。Deletes this conditional format.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

delete(): void;

返回

void

getRange()

返回应用条件格式的范围。Returns the range the conditonal format is applied to. 如果将条件格式应用于多个区域, 则会引发错误。Throws an error if the conditional format is applied to multiple ranges. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

getRange(): Excel.Range;

返回

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const worksheetRange = sheet.getRange();
    worksheetRange.conditionalFormats.load("type");

    await context.sync();

    let cfRangePairs: { cf: Excel.ConditionalFormat, range: Excel.Range }[] = [];
    worksheetRange.conditionalFormats.items.forEach(item => {
        cfRangePairs.push({
            cf: item,
            range: item.getRange().load("address")
        });
    });

    await context.sync();

    if (cfRangePairs.length > 0) {
        cfRangePairs.forEach(item => {
            console.log(item.cf.type);
        });
    } else {
        console.log("No conditional formats applied.");
    }
});

getRangeOrNullObject()

返回条件格式应用于的区域; 或者, 如果将条件格式应用于多个区域, 则返回 null 对象。Returns the range the conditonal format is applied to, or a null object if the conditional format is applied to multiple ranges. 只读。Read-only.

[API 集: ExcelApi 1.6][ API set: ExcelApi 1.6 ]

getRangeOrNullObject(): Excel.Range;

返回

getRanges()

返回将为其应用条件格式的 RangeAreas,它包含一个或多个矩形区域。Returns the RangeAreas, comprising one or more rectangular ranges, the conditonal format is applied to. 只读。Read-only.

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

getRanges(): Excel.RangeAreas;

返回

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.ConditionalFormatLoadOptions): Excel.ConditionalFormat;

参数

返回

注解

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

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

参数

propertyNames
string | string[]

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

返回

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.ConditionalFormat;

参数

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.ConditionalFormatUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Interfaces.ConditionalFormatUpdateData

一个 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.ConditionalFormat): void

set(properties)

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

set(properties: Excel.ConditionalFormat): void;

参数

返回

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

toJSON(): Excel.Interfaces.ConditionalFormatData;

返回