在读取价值之前刷新实时Google Finance数据 [英] Refresh live Google Finance data prior to reading value
问题描述
我正在尝试将内容从一列复制到另一列.
来源"列包含基于公式的内容,例如=GOOGLEFINANCE(SYMBOL,"PRICE")
,该内容每分钟都会更新一次.
I am trying to copy content from one column to another.
Source column has formula based content like =GOOGLEFINANCE(SYMBOL,"PRICE")
which gets updated every minute.
我创建了触发器,该触发器每5分钟运行一次.但是在复制时,它不会复制工作表中显示的最新值,而是从公式中复制初始值.可以说初始库存值为100,后来变为105.当函数运行时,我的脚本将100复制到目标范围.
I have created trigger which runs for every 5min. But while copying it doesn't copy latest value which is seen in sheet, instead it copies initial value from formula. Lets say initial stock value is 100, later it changes to 105. When the function runs, my script copies 100 to the destination range.
...
var ss = SpreadsheetApp.getActive().getSheetByName("Sheet1");
ss.getRange(startRowRange).copyTo(ss.getRange(col), {contentsOnly:true});
如何读取=GOOGLEFINANCE()
单元格的当前显示值?
How can I read the current, displayed value of =GOOGLEFINANCE()
cells?
推荐答案
按照 @tehhowch 的建议,flush
确实做到了诀窍.
调用此命令将应用该时间点所有未完成的电子表格更改.
As @tehhowch suggested, flush
did the trick.
Calling this applies all pending Spreadsheet changes at that point of time.
var ss = SpreadsheetApp.getActive().getSheetByName("Sheet1");
SpreadsheetApp.flush();
ss.getRange(startRowRange).copyTo(ss.getRange(col), {contentsOnly:true});
这篇关于在读取价值之前刷新实时Google Finance数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!