gpt4 book ai didi

google-apps-script - 获取调用自定义函数的电子表格单元格

转载 作者:行者123 更新时间:2023-12-04 19:32:42 44 4
gpt4 key购买 nike

我试图弄清楚如何获得调用自定义函数的单元格的 A1 表示法。

我发现了这个,但这是针对事件单元格的。 https://webapps.stackexchange.com/questions/54414/in-google-script-get-the-spreadsheet-cell-calling-a-custom-function

本质上,如果我想让 Cell A5 调用 =TEST() .我希望函数返回文本值 A5。

我想将其用作 API 调用的缓存标识符。

最佳答案

不同的范围返回方法名称存在细微差别- active , current , selection :

The term "active range" refers to the range that a user has selected in the active sheet, but in a custom function it refers to the cell being "active"ly recalculated.

The current cell is the cell that has focus in the Google Sheets UI, and is highlighted by a dark border.

A selection is the set of cells the user has highlighted in the sheet, which can be non-adjacent ranges. One cell in the selection is the current cell, where the user's current focus is.


前两个仍然是范围对象,而后者不是。

I want the function to return the text value A5.


没有自定义函数,我们可以使用:
=ADDRESS(ROW(),COLUMN())
使用自定义功能,我们可以使用:
function test() { 
return SpreadsheetApp.getActiveRange().getA1Notation();
}

关于google-apps-script - 获取调用自定义函数的电子表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51311286/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com