简体   繁体   English

如何加粗变量的值?

[英]How to bold the value of a variable?

In Google Sheets Script, how do I format a variable that uses .getValue() in bold in HTML?在 Google 表格脚本中,如何在 HTML 中格式化使用.getValue()粗体的变量?

For instance:例如:

var test = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Portfolio").getRange("A1").getValue();
var html = "<strong> test </strong>"

I think that there are no "bold values".我认为没有“大胆的价值观”。 But you can format the range bold with the method setFontWeight in the Range class.但是您可以使用范围class中的 setFontWeight 方法格式化范围粗体。 So in your example:所以在你的例子中:

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Portfolio");
var cell = sheet.getRange("A1");
cell.setFontWeight("bold");

Answer:回答:

You need to use the + operator to concatenate a string.您需要使用+运算符来连接字符串。

Code Fix:代码修复:

var html = "<strong> test </strong>"

should be:应该:

var html = "<strong> " + test + " </strong>"

I hope this is helpful to you!我希望这对你有帮助!

References:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM