Microsoft Graph で Excel のブック関数を使用するUse workbook functions in Excel with Microsoft Graph
どのブック関数も、POST /workbook/functions/{function-name}
という構文を使用することにより呼び出すことができますYou can invoke any workbook function by using the following syntax: POST /workbook/functions/{function-name}
. 本文の中で関数の引数は、JSON オブジェクトを使用して指定します。You provide the function argument(s) in the body using a JSON object. 関数の結果としての value
および任意の error
文字列が、関数の結果のオブジェクトに返されます。The function's resulting value
and any error
strings are returned in the function result object. null
の error
値は、関数の実行が成功したことを示します。The error
value of null
indicates successful execution of the function.
サポートされている関数の完全な一覧は、こちら です。特定のパラメーター名とデータ型については関数のシグネチャを参照してください。The complete list of supported functions are listed here. Refer to the function signature for specific parameter names and data types.
_重要な注意点: _Important notes:
- 範囲入力パラメーターは、範囲のアドレス文字列ではなく、range オブジェクトを使用して提供されます。The range input parameter is supplied using a range object instead of the range address string.
- Index パラメーターは、API のほとんどで使用されている 0 オリジンとは異なり、1 オリジンのインデックス (添字が 1 から始まる) です。The index parameter is 1-indexed unlike the 0-index used in most of the APIs.
例: vlookupExample: vlookup
Excel スプレッドシートで、vlookup
関数は次の引数を取ります。In an Excel spreadsheet, the vlookup
function takes the following arguments:
- lookup_value (必須) 検索する値。lookup_value (required) The value you want to look up.
- table_array (必須) 参照値を検索するセルの範囲。table_array (required) The range of cells where the lookup value is located. 参照値が正しく動作するには、常に VLOOKUP の範囲で参照値が最初の列にある必要があることに留意してください。Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. たとえば、参照値がセル C2 にある場合、範囲は C 列から始まる必要があります。For example, if your lookup value is in cell C2 then your range should start with C.
- col_index_num (必須) 範囲内で、戻り値が入れられる列番号。col_index_num (required) The column number in the range that contains the return value. たとえば、B2: D11 を範囲として指定すると、B を最初の列、C を 2 番目の列というようにカウントする必要があります。For example, if you specify B2: D11 as the range, you should count B as the first column, C as the second, and so on.
- range_lookup (オプション) VLOOKUP で近似値を検索するのか、それとも完全一致を検索するのかを指定する論理値。range_lookup (optional) The logical value that specifies whether you want VLOOKUP to find an approximate or an exact match. 戻り値として近似一致を使用する場合は TRUE を指定し、完全一致を必要とする場合は FALSE を指定します。Specify TRUE if you want an approximate match or FALSE if you want an exact match of the return value. 何も指定しない場合、既定値は常に TRUE、つまり近似一致になります。If you don't specify anything, the default value will always be TRUE or approximate match.
セル内では、vlookup
関数は次のようになります。Inside a cell, the vlookup
function looks like this:
=VLOOKUP(<参照値>, <参照値を含む範囲>, <戻り値を含む範囲内の列番号>, <近似一致には TRUE、完全一致には FALSE をオプションで指定>)=VLOOKUP(lookup value, range containing the lookup value, the column number in the range containing the return value, optionally specify TRUE for approximate match or FALSE for an exact match)
(VLOOKUP Excel 関数についてのドキュメントを参照してください。)(See the documentation for the VLOOKUP Excel function.)
要求:Request:
次の例では、Excel REST API で vlookup
関数を呼び出し、これらのパラメーターを渡す方法を示しています。The following example shows how to call the vlookup
function and pass these parameters with the Excel REST API.
POST https://graph.microsoft.com/beta/me/drive/root:/book1.xlsx:/workbook/functions/vlookup
content-type: Application/Json
authorization: Bearer {access-token}
workbook-session-id: {session-id}
{
"lookupValue": "Temperature",
"tableArray": { "Address": "Sheet1!E1:G5" },
"colIndexNum": 2,
"rangeLookup": false
}
応答Response
HTTP code: 200 OK
content-type: application/json;odata.metadata
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#workbookFunctionResult",
"@odata.type": "#microsoft.graph.workbookFunctionResult",
"@odata.id": "/users('f6d92604-4b76-4b70-9a4c-93dfbcc054d5')/drive/root/workbook/functions/vlookup()",
"error": null,
"value": "28.3"
}
例: median
Example: median
Excel スプレッドシートでは、median
関数は 1 つ以上の入力範囲の配列を取ります。In an Excel spreadsheet, the median
function takes an array of one or more input ranges.
セル内では、median
関数は次の例のようになります。Inside a cell, the median
function looks like this example:
=MEDIAN(A2:A6)=MEDIAN(A2:A6)
(MEDIAN Excel 関数についてのドキュメントを参照してください。)(See the documentation for the MEDIAN Excel function.)
要求Request
次の例では、Excel REST API で median
関数と 1 つ以上の入力範囲を呼び出す方法を示しています。The following example shows how to call the median
function and one or more input ranges with the Excel REST API.
POST https://graph.microsoft.com/beta/me/drive/root:/book1.xlsx:/workbook/functions/median
content-type: Application/Json
authorization: Bearer {access-token}
workbook-session-id: {session-id}
{
"values" : [
{ "address": "Sheet2!A1:A5" },
{ "address": "Sheet2!B1:B5" },
]
}
応答Response
HTTP code: 200 OK
content-type: application/json;odata.metadata
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#workbookFunctionResult",
"@odata.type": "#microsoft.graph.workbookFunctionResult",
"@odata.id": "/users('2abcad6a-2fca-4b6e-9577-e358a757d77d')/drive/root/workbook/functions/median()",
"error": null,
"value": 30
}
関連項目See also
- Microsoft Graph で Excel のセッションを管理するManage sessions in Excel with Microsoft Graph
- Microsoft Graph を使用して Excel ブックに書き込むWrite to an Excel workbook using Microsoft Graph
- Microsoft Graph により Excel のある範囲の書式を更新するUpdate a range’s format in Excel with Microsoft Graph
- Microsoft Graph により Excel のグラフ イメージを表示するDisplay a chart image in Excel with Microsoft Graph
- Excel REST API を使用するUse the Excel REST API