Google电子表格脚本不更新动态信息 [英] Google Spreadsheet Script not Updating Dynamic Info

查看:108
本文介绍了Google电子表格脚本不更新动态信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我为Minecraft制作了一个电子表格,并且给Feed Beast提供了一个游戏的modpack。我的电子表格列出了为最新版本的Minecraft更新的所有模块。最近,我做了一个脚本出去解析mod版本号的页面。他们改变每天每小时,我宁愿不手动。

 函数GetVersion(url,slice,num1,num2){
var r = UrlFetchApp.fetch(url).getContentText();
var version = r.slice(r.indexOf(slice))。slice(num1,num2);

返回版本;
}

在其中一个单元格中,有以下元素:

  = GetVersion(http://files.minecraftforge.net,Build 7.,12,15)

现在,这工作正常,并让我的版本号即时寻找。问题是,当更新发生并出现新版本时,即使关闭窗口并重新打开电子表格或重新加载或其他任何内容,解析器也不会反映这一点!如果我稍微改变上面的内容,比如将15更改为16,它会刷新,但之后会再次卡住,直到我再次手动更改它为止。



我如何所以它至少刷新时,我重新加载工作表?



编辑:好吧,首先,我尝试进入reosources和触发器,触发非常小,每次打开文档。这没有工作..............然后我试图变得聪明。注意到公式重新评估时,我会改变它,我推测公式本身或细胞参数需要改变,以便发生这种情况。因此,我在公式中传递了一个虚拟参数,并更改该参数以更新单元格。



但是这很烦人,并且让我不得不编辑(或者按下按钮)来让狗屎刷新。

所以我得到了一个灵感,并且我现在在dummy参数中传递了GoogleClock()。所有单元现在每60秒更新一次。 yay



有没有更好的方法来做到这一点? 使用googleclock作为参数是最好的,你可以做,如果你想使用自定义cel公式。
改为从菜单项和/或onOpen / time触发器调用更新函数。


So, i made a spreadsheet for Minecraft and 'Feed The Beast' a modpack for the game. My spreadsheet lists all the mods that are updated for the latest version of Minecraft. Recently i made a script to go out and parse pages for mod version numbers. They change hourly-daily and i rather not do it manually.

function GetVersion(url, slice, num1, num2) {
  var r = UrlFetchApp.fetch(url).getContentText();
  var version = r.slice(r.indexOf(slice)).slice(num1, num2);

  return version;
}

In one of the cells Ill have the following

 =GetVersion("http://files.minecraftforge.net", "Build 7.", 12, 15)

Now this works fine and gets me the version number im looking for. The problem is, when an update happens and a new version comes out, the parser doesn't reflect this even if i close the window and reopen the spreadsheet or reload or whatever else! If I change the above slightly, like change the 15 to 16, it will refresh, but then will be stuck there again until i manually change it again.

How do I get it so it at least refreshed when i reload the sheet?

Edit: Alright first I tried to go into reosources and triggers and make a trigger very min and everytime the doc is opened. This didn work..............

Then I tried to get clever. Noticing that the formula reevaluates whenever I change it, i surmised that the formula itself or the cell parameters needs to change in order for this to happen. So I pass a dummy parameter though in the formula and change that parameter to update the cell.

But that's annoying and make me have to edit (or press a button) just to get shit to refresh.

So i got a brainwave and Im now passing GoogleClock() in the dummy parameter. All cells now update on their own every 60 seconds. yay

Is there a better way to do this?

解决方案

Using googleclock as a param is the best u can do if u want to use a custom cel formula. Instead call an update function from a menu item and/or onOpen / time trigger.

这篇关于Google电子表格脚本不更新动态信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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