【问题标题】:Changing font-weight of partial cell value in Google Sheet using Google App script使用 Google App 脚本更改 Google Sheet 中部分单元格值的字体粗细
【发布时间】:2017-04-18 06:47:42
【问题描述】:

要使用 Google App 脚本更改 Google trix 中单元格值的字体粗细,我使用的是“setFontWeight”。但是,如果我需要用粗体显示给定的单词,而不是整个单元格值。请在下图中查看预期结果 -

如何使用 Google App 脚本更改 Google Sheet 中部分单元格值的字体粗细?

【问题讨论】:

    标签: google-apps-script google-sheets text-formatting


    【解决方案1】:

    根据yesterday's release notes(2019 年 1 月 22 日),电子表格服务已扩展为包括 RichTextValue 等新类,现在可以设置部分文本的格式。

    来自Class RichTextValueBuilder的示例

    // Creates a Rich Text value for the text "HelloWorld", with "Hello" bolded, and "World"
    // italicized.
    var bold = SpreadsheetApp.newTextStyle().setBold(true).build();
    var italic = SpreadsheetApp.newTextStyle().setItalic(true).build();
    var value = SpreadsheetApp.newRichTextValue()
        .setText("HelloWorld")
        .setTextStyle(0, 5, bold)
        .setTextStyle(5, 10, italic)
        .build();
    

    【讨论】:

      【解决方案2】:

      很遗憾,(截至目前)您无法通过 Apps 脚本以编程方式修改单元格的一部分。这是一个已经发生的问题。

      https://issuetracker.google.com/issues/36764247

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-01
        • 1970-01-01
        • 2023-01-07
        • 1970-01-01
        • 1970-01-01
        • 2019-01-02
        相关资源
        最近更新 更多