---
schema_version: "1"
id: 4569ed5554040264d3c81c8c4085f25e8ac2503d5519a48793e88bb360ba982f
title: Excel 形式
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.3/dataweave-formats-excel.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.3/dataweave-formats-excel
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 826ef4fc4df6d5db551c6cc5333c7ed7de6ecc01ebd3cd1624f77667d8a954ce
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
# Excel 形式

MIME タイプ: `application/xlsx`

ID: `excel`

Excel ワークブックは一連のシートです。DataWeave では、これはオブジェクトにマップされ、各シートがキーになります。Excel シートごとに 1 つのテーブルのみが許可されます。 テーブルは行の配列として表現されます。行はオブジェクトであり、そのキーが列、値がセルのコンテンツになります。

<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p><code>.xlsx</code>​ ファイルのみがサポートされます (Excel 2007)。  <code>.xls</code>​ ファイルは Mule ではサポートされません。</p>
</div>
</td>
</tr>
</tbody></table>

Excel 入力の DataWeave リーダーでは、次の解析戦略がサポートされています。

- メモリ内
- ストリーミング

DataWeave リーダーおよびライターでこの形式に適用できる解析戦略を理解するには、​[「DataWeave 解析戦略」](https://docs.mulesoft.com/jp/dataweave/2.3/dataweave-formats#dw_readers_writers)​を参照してください。

## [](#mapping)Excel 型のマッピング

次の表に、Excel と DataWeave の型のマッピングを示します。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Excel 型</th>
<th class="tableblock halign-left valign-top">DataWeave 型</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Numeric</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Number</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Data</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Date</code></p></td>
</tr>
</tbody>
</table>

## [](#examples)例

次の例は、Excel 形式の使用方法を示しています。

- [例: Excel を DataWeave (dw) 形式で表す](#example1)
- [例: Excel テーブルを出力する](#example2)
- [例: Excel 入力をストリーミングする](#example3)

### [](#example1)例: Excel を DataWeave (dw) 形式で表す

次の例は、DataWeave で Excel ワークブックを表す方法を示しています。

#### [](#入力)入力

Excel ワークブック (​`Sheet1`​) は、DataWeave ソースの入力ペイロードとして機能します。

Sheet1:

.   | A    | B
1   | Id   | Name
2   | 123  | George
3   | 456  | Lucas

#### [](#ソース)ソース

この DataWeave スクリプトは、Excel 入力ペイロードを DataWeave (dw) 形式と MIME タイプに変換します。

```dataweave
%dw 2.0
output application/dw
---
payload
```

#### [](#出力)出力

DataWeave 出力は次のようになります。他のオブジェクトの値を選択するときと同じ方法で値を選択できます。

```dataweave
{
    "Sheet1": [
        {
                "A": 123,
                "B": "George"
        },
        {
                "A": 456,
                "B": "Lucas"
        }
    ]
}
```

### [](#example2)例: Excel テーブルを出力する

次の DataWeave スクリプトは、ヘッダーと項目が含まれる Excel テーブルを出力します。

この DataWeave スクリプトの本文は、Excel シートのコンテンツを定義する DataWeave オブジェクトです。シートの名前 ​`Sheet1`​ は、このオブジェクトのキーになります。値は、オブジェクトの配列になります。配列の各オブジェクトには、キー-値ペアのコレクションが含まれます。各ペアのキーは、スプレッドシートのヘッダー値として処理されます。各ペアの値は、シートの行のデータ値として処理されます。

この出力ディレクティブは、出力が Excel 形式と MIME タイプであることを示しています。​`header=true`​ 設定は、出力にヘッダー値が含まれていることを示します。

```dataweave
%dw 2.0
output application/xlsx header=true
---
{
  Sheet1: [
    {
      Id: 123,
      Name: George
    },
    {
      Id: 456,
      Name: Lucas
    }
  ]
}
```

他の例については、​[「Excel (XLSX) ファイルのデータの参照」](https://docs.mulesoft.com/jp/dataweave/2.3/dataweave-cookbook-xlsx-lookup)​を参照してください。

### [](#example3)例: Excel 入力をストリーミングする

デフォルトでは、Excel リーダーは、ファイルが 1.5MB 以下の場合、ファイル全体から入力データをメモリ内に保存します。ファイルが 1.5 MB よりも大きい場合、データはディスクに書き込まれます。非常に大きなファイルの場合は、​`streaming`​ プロパティを ​`true`​ に設定することで、リーダーのパフォーマンスを向上できます。

Mule アプリケーションの次の設定 XML では、Excel ファイルをストリーミングして JSON に変換します。

```xml
<http:listener-config
    name="HTTP_Listener_config"
    doc:name="HTTP Listener config" >
  <http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="streaming_flow" >
  <http:listener
    doc:name="Listener"
    config-ref="HTTP_Listener_config"
    path="/"
    outputMimeType="application/xlsx; streaming=true"/>
  <ee:transform doc:name="Transform Message" >
    <ee:message >
      <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload."Sheet Name" map ((row) -> {
    foo: row.a,
    bar: row.b
})]]></ee:set-payload>
    </ee:message>
  </ee:transform>
</flow>
```

この例の説明:

- `outputMimeType="application/xlsx; streaming=true"`​ を設定して、XLSX 入力をストリーミングするように HTTP リスナーを設定します。 Studio UI では、リスナーの ​**\[MIME Type (MIME タイプ)\]**​ を ​`application/xlsx`​ に設定し、MIME タイプの ​**\[Parameters (パラメーター)\]**​ を ​**\[Key (キー)\]**​ ​`streaming`​ と ​**\[Value (値)\]**​ ​`true`​ に設定できます。
- **Transform Message**​ コンポーネントの DataWeave スクリプトを使用して、XLSX ペイロード (​`"Sheet Name"`​ という名前の XLSX シート) の各行を反復処理し、(​`row.a`​、​`row.b`​ を使用して) 行の各セルの値を選択します。​`a`​ および ​`b`​ という名前の列を想定し、それらの列の各行の値を ​`foo`​ および ​`bar`​ にそれぞれマップします。

#### [](#出力-2)出力

次の画像は、Excel テーブルの出力を示しています。

![ID と名前が表示されている Excel 形式のテーブル](/mulesoft/current/ja-jp/dataweave/2.3/_images/dataweave-formats-exceltable.png)

## [](#properties)Configuration のプロパティ

DataWeave では、Excel の次の設定プロパティがサポートされています。

### [](#リーダープロパティ-excel)リーダープロパティ (Excel)

Excel 形式では、入力データの読み込みの指示を提供するプロパティを使用できます。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 50.0002%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">パラメーター</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">デフォルト</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>header</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Excel テーブルにヘッダーを含めるかどうかを示します。有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ignoreEmptyLine</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>空の行を無視するかどうかを示します。有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>streaming</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>false</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Mule 4.2.2 で導入済み: ストリーミングの目的は、大きなファイルを処理することです。ストリーミングを有効にすると、リーダーは一度にすべてのデータを使用可能にするのではなく、各行に順次アクセスして一度に 1 行ずつメモリ内に保存します。ストリーミングでは、ファイルの行にランダムアクセスできません。エントリを順次アクセスする場合のみ使用します。有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>tableOffset</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>null</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>テーブルの最初のセルの位置 (​<code>&lt;Column&gt;&lt;Row&gt; example A1</code>​)。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>zipBombCheck</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><code>false</code>​ に設定すると、zip 爆弾チェックがオフになります。有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。</p>
</div></div></td>
</tr>
</tbody>
</table>

### [](#ライタープロパティ-excel)ライタープロパティ (Excel)

Excel 形式では、出力データの書き込みの指示を提供するプロパティを使用できます。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 16.6666%;">
<col style="width: 50.0002%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">パラメーター</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">デフォルト</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>bufferSize</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Number</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>8192</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ライターバッファのサイズ。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>deferred</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>false</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><code>true</code>​ に設定すると、DataWeave は出力をデータストリームとして生成し、スクリプトの実行はそれがコンシュームされるまで延期されます。
  有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>header</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Excel テーブルにヘッダーを含めるかどうかを示します。有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。ヘッダーがない場合、列名が使用されます (例: A、B、C など)。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ignoreEmptyLine</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>空の行を無視するかどうかを示します。有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>tableOffset</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>null</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>テーブルの最初のセルの位置 (​<code>&lt;Column&gt;&lt;Row&gt; example A1</code>​)。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>zipBombCheck</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true</code></p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><code>false</code>​ に設定すると、zip 爆弾チェックがオフになります。有効な値は、​<code>true</code>​ または ​<code>false</code>​ です。</p>
</div></div></td>
</tr>
</tbody>
</table>

## [](#mime_type)サポートされる MIME タイプ (Excel)

DataWeave では、次の MIME タイプがサポートされています。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 100%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">MIME タイプ</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>application/xlsx</code></p></td>
</tr>
</tbody>
</table>