gpt4 book ai didi

charts - Google 电子表格 sheet.getCharts() 仅在打开电子表格时有效?

转载 作者:行者123 更新时间:2023-12-03 21:45:35 24 4
gpt4 key购买 nike

当电子表格关闭时,我无法获取工作表的图表。我的目标是更新图表并将其作为电子邮件发送,当 Google 电子表格打开时,我已经轻松地做到了这一点。但是当CLOSED时,图表的长度为“0”。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var charts = ss.getSheetByName("Sheet").getCharts();

那么,使用这个命令时有什么限制吗?还是我遗漏了什么?

最佳答案

getActiveSpreadsheet 仅在存在事件电子表格时才有效。 (即:打开电子表格时。)

您应该通过 Class SpreadsheetApp 中详述的打开方法之一打开电子表格(特别是 openopenByIdopenByUrl),然后设置它首先处于事件状态。

例如:

var testSpreadsheet = SpreadsheetApp.openById("1234567890");
SpreadsheetApp.setActiveSpreadsheet(testSpreadsheet);

关于charts - Google 电子表格 sheet.getCharts() 仅在打开电子表格时有效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16267840/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com