WPS 基础接口 > 表格 API 参考 > Application > 属性 > Application.ReplaceFormat 属性
设置替换条件以用于替换单元格格式。该替换条件将在后续调用中被用于 Range 对象的 Replace 方法。

语法

表达式.ReplaceFormat

表达式   一个代表 Application 对象的变量。

示例

在下例中,设置了搜索条件以查找文字为 Arial、常规和 10 号字体的单元格,然后调用 Replace 方法,并将 SearchFormat 和 ReplaceFormat 的可选参数设置为 True 以便进行更改。

示例代码
function MakeBold(){
    // Establish search criteria.
    let finder = Application.FindFormat.Font
    finder.Name = "Arial"
    finder.FontStyle = "Regular"
    finder.Size = 10

    // Establish replacement criteria.
    let replacer = Application.ReplaceFormat.Font
    replacer.Name = "Arial"
    replacer.FontStyle = "Bold"
    replacer.Size = 8

    // Notify user.
    MsgBox(replacer.Name + "-" + replacer.FontStyle + "-" + replacer.Size + " font is what the search criteria will replace cell formats with.")

    // Make the replacements in the worksheet.
    Cells.Replace("", "", undefined, undefined, undefined, undefined, true, true)
}


请参阅