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 format has a limitation of 65535 rows and 256 columns.
The output Excel file will contain a single sheet. The name of the sheet will be the same as the file name without .xls or .xlsx.
Syntax
arcpy.conversion.TableToExcel(Input_Table, Output_Excel_File, {Use_field_alias_as_column_header}, {Use_domain_and_subtype_description})
Parameter | Explanation | Data Type |
Input_Table | The table to be converted to Microsoft Excel. | Table View |
Output_Excel_File | The output Excel file. Specify the format of the Excel file using an .xls or .xlsx file extension. | File |
Use_field_alias_as_column_header (Optional) | Specifies how column names in the output are determined.
| Boolean |
Use_domain_and_subtype_description (Optional) | Controls how values from subtype fields or fields with a coded value domain are 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.TableToExcel_conversion("gdb.gdb/addresses", "addresses.xls")
Converts a table to a Microsoft Excel workbook.
# Name: TableToExcel_2.py
import arcpy
# Set environment settings
arcpy.env.workspace = "c:/data"
# Set local variables
in_table = "gdb.gdb/addresses"
out_xls = "addresses.xls"
# Execute TableToExcel
arcpy.TableToExcel_conversion(in_table, out_xls)
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes