Google finance 作为 ArrayFormula 的参数

Google finance as an argument for ArrayFormula

=ARRAYFORMULA(IF(ROW(B:B)=1, "Share Price", IF(ISBLANK(B:B), "", googlefinance(B:B, "price"))))

我正在尝试让第 1 行(我的 header 行)有一个名称,然后在其下方,如果有效的股票代码是 B 列中的输入,则 google finance fetch该股票的价格。但是,我在 "share price" 下面的所有单元格中都得到了 N/A 并且无法弄清楚为什么。

请帮忙。

编辑:Link 到 sheet: https://docs.google.com/spreadsheets/d/1lyYYzLrFHfjojlL27bQ6ligNz2DBVpSM24jYfAVBVQs/edit?usp=sharing

GOOGLEFINANCE 已经有点像 ArrayFormula,所以这不会像您期望的那样工作...

您将需要使用脚本:

function onOpen(e){this.arrayThis("C1:C");}    //COLUMN WHERE YOU WANT TO HAVE THE RESULT
function arrayThis(range){
SpreadsheetApp.getActiveSpreadsheet().getRange(range).setValue(SpreadsheetApp.getActiveSpreadsheet().getRange(range).getCell(1,1).getFormula());
}

C1 需要位于:

=IF(ROW(B1)=1, "Share Price", IF(B1="",,GOOGLEFINANCE(B1, "price")))