要使用 Google App 脚本更改 Google trix 中单元格值的字体粗细,我使用了“setFontWeight”。但是,如果我需要以粗体显示给定的单词,而不是整个单元格值。请在下图中查看预期结果 -
如何使用 Google App 脚本更改 Google Sheet 中部分单元格值的字体粗细?
最佳答案
根据 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();
关于google-apps-script - 使用 Google App 脚本更改 Google Sheet 中部分单元格值的字体粗细,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43465402/