You need to include sheets
in the addOns section of the manifest, as specified here. The documentation for add-ons is available at https://developers.google.com/gsuite/add-ons/overview
Here's a simplified example derived from Quickstart: Cats Google Workspace Add-on
Code.gs
function onHomepage(e) {
return CardService.newCardBuilder().addSection(
CardService.newCardSection().setHeader('Header').addWidget(
CardService.newTextParagraph().setText('Paragraph')
)
).build();
}
appsscript.json (manifest)
{
"timeZone": "Etc/GMT",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"addOns": {
"common": {
"name": "Cats",
"logoUrl": "https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png",
"homepageTrigger": {
"runFunction": "onHomepage",
"enabled": true
}
},
"sheets": {}
}
}
The homepageTrigger
doesn't need to be in the common section. You could include place it directly within sheets
instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…