如何使Google表格每60秒刷新一次? [英] How do I make Google Sheets refresh every 60 seconds?

查看:124
本文介绍了如何使Google表格每60秒刷新一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Google表格中有一个ImportJSON脚本,该脚本是从此处检索到的。现在我有了代码:

I have an ImportJSON script in my Google Sheets retrieved from here. Now I have code:

=ImportJSON("http://date.jsontest.com/","/time", "")

现在可以简单地获取时间。我的问题是它不会自动刷新。

which simply retrieves the time right now. My issue is that it does not refresh automatically.

如何使其每60秒刷新一次?

How do I make it refresh every 60 seconds?

推荐答案

我在Google Apps脚本中使用刷新脚本。

I use a refresh script with the google apps script.

首先,您需要生成一个随机数,以诱骗它以为它是一个新链接。

First you need to generate a random number to trick it into thinking its a new link.

  var min = Math.ceil(0);
  var max = Math.floor(99);
  var randomNum = Math.floor(Math.random() * (max - min + 1)) + min

之后,您需要写一些您想要的时间

After that you need to write to the cell you want to have the time

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Sheet1");

sh.getRange("A1").setFormula('=ImportJSON("http://date.jsontest.com/","/time", "","' + randomNum +'")';

然后,您可以将脚本设置为随时运行。

Then you can set up the script to run whenever you want.

这篇关于如何使Google表格每60秒刷新一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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