您无权调用 setDataValidation

You do not have permission to call setDataValidation

我正在尝试使用自定义函数。每当我尝试将它用作工作表中的公式并在单元格上使用 运行 时,它都会抛出错误:

You do not have permission to call setDataValidation

但是当我从脚本编辑器 运行 它时,它 运行 完全没问题。如何在不从脚本编辑器中单击 Run 的情况下使其工作?

注意:我不喜欢使用触发器。

SpreadsheetApp 服务在使用自定义函数调用时是只读的

Ocordova 的想法是正确的。 article he cited 讨论了 SpreadsheetApp 服务如何...

Read only (can use most get*() methods, but not set*()). Cannot open other spreadsheets (SpreadsheetApp.openById() or SpreadsheetApp.openByUrl()).

如果您希望能够编辑单元格,则需要从自定义菜单中调用这些功能。