我有一个脚本可以从Google表格创建日历事件。 它运行良好,但我想在日历事件描述中加粗某些文本。 我似乎找不到办法做到这一点! 有什么建议吗?
顺便说一句,它现在只是设置为读取一行,以便我可以测试它......
这是我的脚本:
'''
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [
{name: 'Sync to Calendar', functionName: 'syncCalendar'},
];
spreadsheet.addMenu('Sync to Calendar', menuItems);
}
function syncCalendar() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = spreadsheet.getRange("C4").getValue();
var eventCal = CalendarApp.getCalendarById("CALENDAR ID");
var signups = spreadsheet.getRange("A32:U32").getValues();
for (x=0; x<signups.length; x++) {
var shift = signups[x];
var buildDate = shift[0];
var steelPO = shift[1];
var name = shift[2];
var size = shift[3];
var install = shift[4];
var fabnotes = shift[5];
var shopnotes = shift[8];
var buildnotes = shift[10];
var leadbuilder = shift[11];
var contact = shift[12];
var location = shift[13];
var advanced = {location:location, description:("Steel PO " + steelPO + "nnLead Builder: " + leadbuilder + "nnContact: " + contact + "nnBuild Notes: " + buildnotes + "nnShop Notes: " + shopnotes + "nnFab Notes: " + fabnotes)};
eventCal.createAllDayEvent((name + " " + size + " " + install), buildDate, advanced);
}
}
您希望将
- 日历事件描述的值设置为粗体类型。
- 您希望使用Google Apps Script实现此目的。
如果我的理解是正确的,那么这个答案呢?
修改点:
- 对于日历事件的描述,可以使用HTML标记。
- 当我检索到具有粗体类型和超链接描述的事件时,我可以注意到使用了 HTML 标记。所以我可以知道能够使用 HTML 标签进行描述。但我找不到有关此的官方文件。所以我不确定是否可以使用所有 HTML 标签。对此,我深表歉意。
修改后的脚本:
作为测试用例,当description
steelPO
设置为粗体类型时,请按如下方式修改。
var advanced = {location:location, description:("Steel PO " + steelPO + "nnLead Builder: " + leadbuilder + "nnContact: " + contact + "nnBuild Notes: " + buildnotes + "nnShop Notes: " + shopnotes + "nnFab Notes: " + fabnotes)};
自:var advanced = {location:location, description:("Steel PO <b>" + steelPO + "</b>nnLead Builder: " + leadbuilder + "nnContact: " + contact + "nnBuild Notes: " + buildnotes + "nnShop Notes: " + shopnotes + "nnFab Notes: " + fabnotes)};
- 添加了
<b>
的 HTML 标记。
参考:
- 创建全天事件(标题,日期,选项(
如果这不是你想要的方向,我很抱歉。