次の方法で共有


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 ファイルで関数オプションで次を指定する必要があります。 { "requiresAddress": true }

JSDoc コメントからメタデータ JSON ファイルが生成されている場合は、タグ @requiresAddressを含めます。

functionName

この関数の名前。

isInValuePreview

関数が数式値プレビューの一部として呼び出されるかどうかを示します。 isInValuePreview は読み取り専用であり、カスタム関数アドインでは設定できません。 この値は、関数が呼び出されて数式値をプレビューする場合は true されます。それ以外の場合は false

parameterAddresses

範囲は、関数パラメーターが配置されている場所 (要求された場合) にアドレスを指定します。それ以外の場合は未定義です。

関数のパラメーター アドレスを要求するには、メタデータ JSON ファイルで関数オプションで次を指定する必要があります。 { "requiresParameterAddresses": true }

JSDoc コメントからメタデータ JSON ファイルが生成されている場合は、タグ @requiresParameterAddressesを含めます。

プロパティの詳細

address

関数が呼び出されているセル アドレス (要求された場合)、それ以外の場合は未定義。

関数のアドレスを要求するには、メタデータ JSON ファイルで関数オプションで次を指定する必要があります。 { "requiresAddress": true }

JSDoc コメントからメタデータ JSON ファイルが生成されている場合は、タグ @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

この関数の名前。

functionName?: string;

プロパティ値

string

注釈

[ API セット: CustomFunctionsRuntime 1.1 ]

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 }

JSDoc コメントからメタデータ JSON ファイルが生成されている場合は、タグ @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;
}