要使用 Google App 脚本更改 Google trix 中单元格值的字体粗细,我使用“setFontWeight”。但是,如果我需要将给定单词加粗,而不是整个单元格值。请参阅下图中的预期结果 -
如何使用 Google App 脚本更改 Google Sheet 中部分单元格值的字体粗细?
根据昨天的发行说明(2019 年 1 月 22 日),电子表格服务已扩展为包含新类,例如 RichTextValue,现在可以设置部分文本的格式。
的示例// 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();
不幸的是(到目前为止)您无法通过 Apps 脚本以编程方式修改单元格的一部分。这是一个已经发生的问题。