![](/img/trans.png)
[英]Use ARRAYFORMULA in a custom script function (Google Sheets + GAS)
[英]How to wait for GAS custom function to finish and then continue using google sheets api?
我正在使用Google Sheets api创建包含多个工作表的电子表格,所有工作表都具有自定义功能 ,该功能是用Google App Script编写的 。 该函数从我的服务器获取数据,通常至少有25个函数调用。
现在,一旦所有自定义功能正确完成后,我想使用Google Sheets api下载文件。
如何等待所有自定义功能 完成 ,然后继续进行Google Sheets API调用?
如果还有其他人在寻找答案,我发现了一种可能并不理想的方法,但它可行。
def check_if_ready(spreadsheet_id):
no_of_retry = 5
response = service.spreadsheets().get(spreadsheetId=spreadsheet_id,fields='sheets(data.rowData.values(effectiveValue))').execute()
i = 1
while 'errorValue' in str(response):
if i > no_of_retry:
return Response({'message': 'Error!'}, status=status.HTTP_404_NOT_FOUND)
response = service.spreadsheets().get(spreadsheetId=spreadsheet_id,fields='sheets(data.rowData.values(effectiveValue))').execute()
time.sleep(5)
i += 1
因为errorValue将返回自定义函数的值,该值未正确计算或在API调用时仍在计算中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.