Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

Reading the values of cells that summarize Google Finance data results via Apps Script

Apps Script seems to be unable to deal with a cell that uses the average formula, when the average is over Google Finance data:

Consider that column A is full of data from Google Finance. Then you type into cell B1 =average(A1:A100). Lets assume the average is 5 and as such cell, B1 shows 5. Great, except that using the following script will fail:

var AveResult = spreadsheet.getRange('B1').getValue();
----> The log show a #DIV/0! error

On the other hand, if you overwrite the formula in B1 and simply type in a 5, then it works perfectly:

var AveResult = spreadsheet.getRange('B1').getValue();
----> The log shows 5

Is there any way to get around this problem, to use scripts with summaries of Google Finance data?

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As written in the Official documentation,

Historical data cannot be downloaded or accessed via the Sheets API or Apps Script. If you attempt to do so, you will see a #N/A error in place of the values in the corresponding cells of your spreadsheet.

The average formula is NOT the problem. Any attempt to take historical finance data through any formula hoops doesn't seem to be possible.

However live data doesn't seem to be restricted the same way.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...