WPS 基础接口 > 表格 API 参考 > FormatCondition > FormatCondition 对象

代表条件格式。

说明

FormatCondition 对象是 FormatConditions 集合的成员。对于给定区域,FormatConditions 集合中包含的条件格式不能超过三个。

使用 Add 方法可新建条件格式。如果区域内存在多种格式,则可使用 Modify 方法更改其中一种格式,或使用 Delete 方法删除一种格式,然后使用 Add 方法创建一种新格式。

使用 FormatCondition 对象的 FontBordersInterior 属性可控制已设置格式的单元格的外观。条件格式对象模型不支持这些对象的某些属性。下表列出所有可与条件格式一起使用的属性。

对象 属性
Font Bold

Color

ColorIndex

FontStyle

Italic

Strikethrough

Underline

无法使用会计用下划线样式。

Border Bottom

Color

Left

Right

Style

可使用下列边框样式(其他均不可用):xlNonexlSolidxlDashxlDotxlDashDotxlDashDotDotxlGray50xlGray75xlGray25

Top

Weight

可使用下列边框粗细(其他均不可用):xlWeightHairlinexlWeightThin

Interior Color

ColorIndex

Pattern

PatternColorIndex

示例

使用 FormatConditions(index)(其中 index 为条件格式的索引号)可返回 FormatCondition 对象。下例为 E1:E10 单元格的现有条件格式设置格式属性。

示例代码
let range2 = Worksheets.Item(1).Range("e1:e10").FormatConditions.Item(1)
    let range3 = range2.Borders
        range3.LineStyle = xlContinuous
        range3.Weight = xlThin
        range3.ColorIndex = 6
    let range4 = range2.Font
        range4.Bold = true
        range4.ColorIndex = 3


请参阅