Posted 5 June 2020, 1:00 am EST
Hi,
You may use a temporary span element to modify only part of the font string. Please refer to the following code snippet and attached sample which demonstrates the same:
let oldFont = sheet
.getCell(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex())
.font(); //get the oldFon for the ActiveCell
let newFont = getModifiedFontString(oldFont, "fontWeight", "bold");
sheet
.getCell(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex())
.font(newFont); //update the newFont
function getModifiedFontString(oldFontString, property, value) {
var span = document.createElement("span");
span.style.font = oldFontString;
span.style[property] = value;
return span.style.font;
}
sample: https://codesandbox.io/s/silly-kare-y3yno?file=/src/index.js
Regards