Table To Excel (Conversion)

Summary

Converts a table to a Microsoft Excel file (.xls or .xlsx).

Usage

  • The extension of the output file controls the output Excel format. If the extension is .xls, the file format will be Excel Binary File Format. If the extension is .xlsx, the file format will be Office Open XML.

  • The .xls file has a limitation of 65,535 rows and 256 columns.

  • The output Excel file can contain multiple sheets. The name of each sheet will be the same as the name of the corresponding input table without the .xls or .xlsx file extension.

    Note:

    The order of appearance for the worksheets will be the same order as they are listed in the parameter. If there is a naming conflict, a number will be appended to the sheet name to ensure that each name remains unique.

  • When converting a table, Timestamp offset fields will be written to Excel as ISO 8601 string values.

Parameters

LabelExplanationData Type
Input Table

The table or tables to be converted to an Excel file.

Table View
Output Excel File (.xls or .xlsx)

The output Excel file. Specify the format of the Excel file using the .xls or .xlsx file extension.

File
Use field alias as column header
(Optional)

Specifies whether input field names or field aliases will be used as the output column names.

  • Unchecked—Column headers will be set using the input field names. This is the default.
  • Checked—Column headers will be set using the input geodatabase table's field aliases. If the input is a layer in a map, the value set on the layer's field alias is ignored.
Boolean
Use domain and subtype description
(Optional)

Specifies whether values from subtype fields or fields with a coded value domain will be transferred to the output.

  • Unchecked—All field values will be used as they are stored in the table. This is the default.
  • Checked—For subtype fields, the subtype description will be used. For fields with a coded value domain, the coded value descriptions will be used.
Boolean

arcpy.conversion.TableToExcel(Input_Table, Output_Excel_File, {Use_field_alias_as_column_header}, {Use_domain_and_subtype_description})
NameExplanationData Type
Input_Table
[Input_Table,...]

The table or tables to be converted to an Excel file.

Table View
Output_Excel_File

The output Excel file. Specify the format of the Excel file using the .xls or .xlsx file extension.

File
Use_field_alias_as_column_header
(Optional)

Specifies whether input field names or field aliases will be used as the output column names.

  • NAMEColumn headers will be set using the input field names. This is the default.
  • ALIASColumn headers will be set using the input geodatabase table's field aliases. If the input is a layer in a map, the value set on the layer's field alias is ignored.
Boolean
Use_domain_and_subtype_description
(Optional)

Specifies whether values from subtype fields or fields with a coded value domain will be transferred to the output.

  • CODEAll field values will be used as they are stored in the table. This is the default.
  • DESCRIPTIONFor subtype fields, the subtype description will be used. For fields with a coded value domain, the coded value descriptions will be used.
Boolean

Code sample

TableToExcel example (Python window)

The following Python window script demonstrates how to use the TableToExcel function in immediate mode.

import arcpy
arcpy.env.workspace = "c:/data"
arcpy.conversion.TableToExcel("gdb.gdb/addresses", "addresses.xls")
TableToExcel example 2 (stand-alone script)

Convert a table to an Excel workbook.

import arcpy

# Set environment settings
arcpy.env.workspace = "c:/data"

# Set local variables
in_table = "gdb.gdb/addresses"
out_xls = "addresses.xls"

# Run TableToExcel
arcpy.conversion.TableToExcel(in_table, out_xls)

Related topics