Excel → テーブル(Excel To Table) (変換)

ライセンス レベル:BasicStandardAdvanced

サマリ

Microsoft Excel ファイルをテーブルに変換します。

使用法

構文

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 for Desktop Basic: ○
ArcGIS for Desktop Standard: ○
ArcGIS for Desktop Advanced: ○
7/28/2014