Changing font-weight of partial cell value in Google Sheet using Google App script

后端 未结 2 773
小蘑菇
小蘑菇 2021-01-21 03:40

To change the font weight of cell value in a Google trix using Google App script, I am using \'setFontWeight\'. However, if I need to make a given word in bold, and not the enti

相关标签:
2条回答
  • 2021-01-21 04:06

    According the the yesterday's release notes (January 22, 2019), the Spreadsheet Service was extended to include new classes like RichTextValue which makes now possible to set formatting for partial text.

    Example from 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();
    
    0 讨论(0)
  • 2021-01-21 04:25

    Unfortunately there is no way (as of now) you can modify part of a cell programically through Apps Script. Here is an issue already going on for this.

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

    0 讨论(0)
提交回复
热议问题