Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我可以从自己制作的库脚本中调用脚本中的函数吗?_Javascript_Google Apps Script_Google Sheets_Google Apps_Google Spreadsheet Api - Fatal编程技术网

Javascript 我可以从自己制作的库脚本中调用脚本中的函数吗?

Javascript 我可以从自己制作的库脚本中调用脚本中的函数吗?,javascript,google-apps-script,google-sheets,google-apps,google-spreadsheet-api,Javascript,Google Apps Script,Google Sheets,Google Apps,Google Spreadsheet Api,这是我的库代码: function simpleEdit(){ var cell = SpreadsheetApp.getActiveSheet().getActiveCell(); cell.setValue('Simple edit made by script'); // Calling a custom script function after doing edit customfunc(); } customfunc位于库之外的其他脚本中,但位于同一

这是我的库代码:

function simpleEdit(){
    var cell = SpreadsheetApp.getActiveSheet().getActiveCell();
    cell.setValue('Simple edit made by script');
    // Calling a custom script function after doing edit
    customfunc();
}
customfunc位于库之外的其他脚本中,但位于同一项目中

代码如下:

function customfunc() {
   SpreadsheetApp.getActiveSheet().getRange('F2').setValue('Hi');
}
脚本调用库函数 函数s { Demog.Simpledit; }
Demog是库标识符

是的,它可以工作。如果发布了一个包含两个脚本文件的库。使用库的脚本可以访问所有未标记为private的方法


但要让您知道getActiveSheet或getActiveSpreadsheet在库中不起作用。即使您发布的脚本包含在电子表格中。它将始终返回null。

是-这应该可以工作-只要这些函数在同一范围内。但当我通过函数s调用它时,它不工作。。库代码作为资源库添加。。项目中没有库脚本代码,因为您的库已发布?demog是库标识符吗?它是否开启了开发模式?有很多事情你可能会做错,所有这些都在文档中,只是从一开始就存在。