Making bold only a part of a Google Spreadsheets c

2019-03-02 04:44发布

问题:

I have a sheet with two columns: "Snippet", containing a paragraph, and "Keywords", containing some comma separated keywords.

I am doing a script so on each row, if any of the keywords appear in the snippet, its appearance becomes bold.

However, I only found ways to make the whole cell bold:

function bold() {
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];
 var lastRow = sheet.getLastRow();
 var keywords = sheet.getLastColumn();
 var snippet = sheet.getLastColumn() - 1;
 var keywordVal = sheet.getRange(lastRow, keywords);

 rangesp = sheet.getRange(lastRow, snippet).setFontWeight("bold")

 }

The setFontWeight seems to take only a range as an input, so I am able to bold a full cell. Is it really possible to do what I intend, and bold only a portion of the cell, rather than the full cell?

回答1:

I discovered that this is currently not possible, but there is an issue open about it:

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