如何在Google表格中编写宏以刷新bigquery数据连接器? [英] How to write a macro in google sheets to refresh a bigquery data connector?
本文介绍了如何在Google表格中编写宏以刷新bigquery数据连接器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试创建刷新BigQuery数据连接的宏.
Trying to create a macro that refreshes a bigquery data connection.
尝试记录宏,从另一个选项卡开始,单击带有数据连接器的选项卡,然后单击刷新.
Have tried to record a macro, starting on a different tab, clicking into the tab with the data connector and clicking refresh.
function Refresh2() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('F3').activate();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Extract 2'), true);
推荐答案
如果您遵循指南在这里,您应该可以做到.
If you follow the guide here, you should be able to do it.
这就是我所拥有的,它可以完美地工作:
Here is what I've got and it works flawlessly:
/** @OnlyCurrentDoc */
function refresh() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A1').activate();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Data Sheet 1'), true);
SpreadsheetApp.enableAllDataSourcesExecution();
spreadsheet.getCurrentCell().getDataSourceTables()[0].refreshData();
};
此讨论可能如果您在刷新BigQuery源代码后又走了一步,就会很有意思.
This discussion may be interesting if you have yet another step after refreshing BigQuery source.
这篇关于如何在Google表格中编写宏以刷新bigquery数据连接器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文