サマリー
Microsoft Excel ファイルをテーブルに変換します。
使用法
- [Excel → テーブル (Excel To Table)] は、Excel Workbook (*.xlsx) および Microsoft Excel 5.0/95 Workbook (*.xls) フォーマットを入力としてサポートしています。 
- このツールは、表データが縦に並べられていることを前提としています。先頭行は、出力テーブルのフィールド名とみなされます。これらのフィールド名は、エラーが起きたり名前が重複しないよう検証プロセス中に名前を変更できます。データとデータの間に空の列がある場合、それらは維持され、汎用的なフィールド名 (たとえば、field_4) が付与されます。 
- 出力フィールドのデータ タイプは、入力列内にあった値とセルの書式設定に基づきます。出力フィールドのデータ タイプには、浮動小数点、テキスト、日付などがあります。入力列に複数のデータまたは書式設定のタイプがある場合、出力フィールドのタイプはテキストになります。 
構文
ExcelToTable_conversion (Input_Excel_File, Output_Table, {Sheet})| パラメーター | 説明 | データ タイプ | 
| Input_Excel_File | 変換する Microsoft Excel。 | File | 
| Output_Table | 出力テーブル。 | Table | 
| Sheet (オプション) | インポートする Excel ファイル内の特定のシートの名前。指定しない場合、ワークブックの最初のシートが使用されます。 | String | 
コードのサンプル
ExcelToTable (Excel → テーブル) の例 (Python ウィンドウ)
次の Python ウィンドウ スクリプトは、イミディエイト モードで ExcelToTable (Excel → テーブル) 関数を使用する方法を示しています。
import arcpy
arcpy.env.workspace = "c:/data"
arcpy.ExcelToTable_conversion("data.xls", "outgdb.gdb", "Sheet1")
ExcelToTable (Excel → テーブル) の例 2 (スタンドアロン スクリプト)
Microsoft Excel ファイルの各シートを、ジオデータベースの各テーブルにインポートします。
import os
import xlrd
import arcpy
def importallsheets(in_excel, out_gdb):
    workbook = xlrd.open_workbook(in_excel)
    sheets = [sheet.name for sheet in workbook.sheets()]
    print('{} sheets found: {}'.format(len(sheets), ','.join(sheets)))
    for sheet in sheets:
        # The out_table is based on the input excel file name
        # a underscore (_) separator followed by the sheet name
        out_table = os.path.join(
            out_gdb,
            arcpy.ValidateTableName(
                "{0}_{1}".format(os.path.basename(in_excel), sheet),
                out_gdb))
        print('Converting {} to {}'.format(sheet, out_table))
        # Perform the conversion
        arcpy.ExcelToTable_conversion(in_excel, out_table, sheet)
if __name__ == '__main__':
    importallsheets('c:/data/data.xls',
                    'c:/data/outgdb.gdb')
環境
ライセンス情報
- ArcGIS Desktop Basic: はい
- ArcGIS Desktop Standard: はい
- ArcGIS Desktop Advanced: はい