Reputation: 329
Here's my code, based on this documentation:
const boldStyle = SpreadsheetApp.newTextStyle()
.setUnderline(false)
.setBold(true)
.setForegroundColor("#000000")
.build();
const testrichtext = SpreadsheetApp.newRichTextValue()
.setText('testing testing testing')
.setLinkUrl(0, 5, "https://bar.foo")
.setTextStyle(7, 10, boldStyle)
.build();
Returns this output which I don't know how to use:
com.google.apps.maestro.server.beans.trix.impl.RichTextValueApiAdapter@13134ed6
the 13134ed6
part changes with each run, so I assume it does build something :)
Any ideas?
Upvotes: 0
Views: 609
Reputation: 2744
You can apply these text styles and rich text values to ranges using the range method setRichTextValue
.
You can just apply the style with setTextStyle
.
const boldStyle = SpreadsheetApp.newTextStyle()
.setUnderline(false)
.setBold(true)
.setForegroundColor("#000000")
.build();
const testrichtext = SpreadsheetApp.newRichTextValue()
.setText('testing testing testing')
.setLinkUrl(0, 5, "https://bar.foo")
.setTextStyle(7, 10, boldStyle)
.build();
function setRichText() {
SpreadsheetApp.getActive().getActiveCell().setRichTextValue(testrichtext);
}
Upvotes: 1