Label | Explanation | Data 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.
| 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.
| Boolean |
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
arcpy.conversion.TableToExcel(Input_Table, Output_Excel_File, {Use_field_alias_as_column_header}, {Use_domain_and_subtype_description})
Name | Explanation | Data 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.
| 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.
| Boolean |
Code sample
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")
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)