CustomFunctions.Invocation interface
カスタム関数の呼び出しに関する情報を提供します。
注釈
例
/**
* Return the address of the cell that invoked the custom function.
* @customfunction
* @param {number} first First parameter.
* @param {number} second Second parameter.
* @param {CustomFunctions.Invocation} invocation Invocation object.
* @requiresAddress
*/
function getAddress(first, second, invocation) {
const address = invocation.address;
return address;
}
プロパティ
| address | 要求された場合、関数が呼び出されているセル アドレス (それ以外の場合は未定義)。 関数のアドレスを要求するには、メタデータ JSON ファイルで関数オプションで以下を指定する必要があります。 メタデータ JSON ファイルが JSDoc コメントから生成されている場合は、タグ |
| function |
この関数の名前です。 |
| is |
関数が数式値のプレビューの一部として呼び出されるかどうかを示します。
|
| parameter |
要求された場合、関数パラメーターが配置されている範囲アドレス (それ以外の場合は未定義)。 関数のパラメーター アドレスを要求するには、メタデータ JSON ファイルで関数オプションで以下を指定する必要があります。 メタデータ JSON ファイルが JSDoc コメントから生成されている場合は、タグ |
プロパティの詳細
address
要求された場合、関数が呼び出されているセル アドレス (それ以外の場合は未定義)。
関数のアドレスを要求するには、メタデータ JSON ファイルで関数オプションで以下を指定する必要があります。 { "requiresAddress": true }
メタデータ JSON ファイルが JSDoc コメントから生成されている場合は、タグ @requiresAddressを含めます。
address?: string;
プロパティ値
string
注釈
API セット: CustomFunctionsRuntime 1.1
例
/**
* Return the address of the cell that invoked the custom function.
* @customfunction
* @param {number} first First parameter.
* @param {number} second Second parameter.
* @param {CustomFunctions.Invocation} invocation Invocation object.
* @requiresAddress
*/
function getAddress(first, second, invocation) {
const address = invocation.address;
return address;
}
functionName
isInValuePreview
関数が数式値のプレビューの一部として呼び出されるかどうかを示します。
isInValuePreview は読み取り専用であり、カスタム関数アドインでは設定できません。 この値は、関数を呼び出して数式の値をプレビューする場合は true 、それ以外の場合は false です。
isInValuePreview?: string;
プロパティ値
string
注釈
API セット: CustomFunctionsRuntime 1.5
例
/**
* Get the listing price for a house on the market for the given address.
* @customfunction
* @param address The address of the house.
* @param invocation Custom function handler.
* @returns The price of the house at the address.
*/
function getHousePrice(address: string, invocation: CustomFunctions.Invocation): number {
// Check if this call is for formula value preview mode.
if (invocation.isInValuePreview) {
// Avoid long-running expensive service calls.
// Return a usable but fake number.
return 450000;
} else {
// Make the actual service calls in this block.
const price = callHouseServiceAPI(address);
return price;
}
}
parameterAddresses
要求された場合、関数パラメーターが配置されている範囲アドレス (それ以外の場合は未定義)。
関数のパラメーター アドレスを要求するには、メタデータ JSON ファイルで関数オプションで以下を指定する必要があります。 { "requiresParameterAddresses": true }
メタデータ JSON ファイルが JSDoc コメントから生成されている場合は、タグ @requiresParameterAddressesを含めます。
parameterAddresses?: string[];
プロパティ値
string[]
注釈
API セット: CustomFunctionsRuntime 1.3
例
/**
* Return the addresses of three parameters.
* @customfunction
* @param {string} firstParameter First parameter.
* @param {string} secondParameter Second parameter.
* @param {string} thirdParameter Third parameter.
* @param {CustomFunctions.Invocation} invocation Invocation object.
* @returns {string[][]} The addresses of the parameters, as a 2-dimensional array.
* @requiresParameterAddresses
*/
function getParameterAddresses(firstParameter, secondParameter, thirdParameter, invocation) {
const addresses = [
[invocation.parameterAddresses[0]],
[invocation.parameterAddresses[1]],
[invocation.parameterAddresses[2]]
];
return addresses;
}