Reputation: 437
I'm concatenating text using goole sheets, but I want to automatically format the text. Is it possible to add to the formula (I tried HTML tags, unsuccessfully)?
Sheets has the ability to display formatted text into a cell that you enter manually through some WYSIWYG editor. But that doesn't seem to work on concatenated text in a line by line fashion, though it will work on the entire cell.
I'm looking for a formula that can be used to process the concatenated text or a suggestion for what the best alternative would be, whether that is a plugin, appscript etc.
Upvotes: 0
Views: 268
Reputation: 14537
You can do it via a custom menu this way:
function onOpen() {
SpreadsheetApp.getUi().createMenu('Scripts')
.addItem('Format header', 'format_header')
.addToUi();
}
function format_header() {
var cell = SpreadsheetApp.getActiveSheet().getCurrentCell();
var text = cell.getValue();
var header = text.split('\n')[0];
var style = SpreadsheetApp.newTextStyle().setBold(true).setFontSize(14).build();
var value = SpreadsheetApp.newRichTextValue().setText(text).setTextStyle(0, header.length, style).build();
cell.setRichTextValue(value);
}
It adds the command 'Format header' in menu 'Scripts' that formats a first line of the text in current cell as bold and size 14.
Upvotes: 1