强制IMPORTRANGE每隔一定时间进行更新 [英] Force IMPORTRANGE to update at certain intervals

查看:161
本文介绍了强制IMPORTRANGE每隔一定时间进行更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些抱怨,它们表示通过Google表格中的IMPORTRANGE进行数据更新的延迟,但是我需要相反的说法,并且不希望第二张表格自动更新,例如,在一天结束时进行更新.

I saw several complains about the delay of updating data through IMPORTRANGE in Google Sheets but I need the opposite and don't want the second sheet to get updated automatically, just update at the end of the day for example.

代码已经像这样:

=IMPORTRANGE("The Key","The_Page!B:D")

推荐答案

也许您需要使用脚本编辑器并编写一个简单的函数:

Maybe you need to use the script editor and write a simple function of the kind:

function importData()
{

var ss = SpreadsheetApp.getActiveSpreadsheet(); //source ss

var sheet = ss.getSheetByName("The_Page");      //opens the sheet with your source data

var values = sheet.getRange("B:D").getValues();   //gets needed values

var ts = SpreadsheetApp.openById("The Key");    //target ss - paste your key

ts.getSheetByName("Name of the target sheet").getRange("B:D").setValues(values);

}

然后向该项目添加一个时间驱动的触发器(资源>当前项目的触发器>添加一个新触发器).

And then add a time-driven trigger to this project (Resources > Current project's triggers > Add a new one).

这篇关于强制IMPORTRANGE每隔一定时间进行更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆