I created a small table (less than 200 rows) then attempted to export to Excel. Table to Excel tool consistently fails.
If send the tool script with my parameters to the Python window and run the tool, the following error results - it is the same and repeatable:
import arcpy
arcpy.conversion.TableToExcel("thesisHistAnalysis", r"C:\Users\PCD\Documents\ArcGIS\Projects\Thesis\thesisHistAnalysis.xlsx", "ALIAS", "DESCRIPTION")
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 99, in TableToExcel
raise e
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 96, in TableToExcel
retval = convertArcObjectToPythonObject(gp.TableToExcel_conversion(*gp_fixargs((Input_Table, Output_Excel_File, Use_field_alias_as_column_header, Use_domain_and_subtype_description), True)))
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Traceback (most recent call last):
File "c:\program files\arcgis\pro\Resources\ArcToolbox\Scripts\TableToExcel.py", line 306, in <module>
arcpy.GetParameter(3))
File "c:\program files\arcgis\pro\Resources\ArcToolbox\Scripts\TableToExcel.py", line 171, in table_to_excel
fields = get_field_defs(in_table, use_domain_desc)
File "c:\program files\arcgis\pro\Resources\ArcToolbox\Scripts\TableToExcel.py", line 123, in get_field_defs
subtypes = arcpy.da.ListSubtypes(in_table)
OSError: thesisHistAnalysis
Failed to execute (TableToExcel).
Is there another approach - maybe a pandas or similar solution if the ESRI script does not work? Is ther a way to troubleshoot ESRI Python that previously operated as anticipated? Are there requirements wrt the table itself that could be related to the error?
I might recommend upgrading the latest version of ArcGIS Pro (2.4.2) and running the workflow again. I know that there have been some improvements in the Excel tools in the latest version
What's new in ArcGIS Pro 2.4—ArcGIS Pro | Documentation - This takes to a specific section that mentions the Excel information.
Work with Microsoft Excel files in ArcGIS Pro—Excel | ArcGIS Desktop
A view of the table might help. It looks like something to do with field names.
Paul, it could be that because the table appears to be a joined table.
Have you tried exporting it to a new table to make the join permanent prior to using Table to Excel. Can't find any documentation on how joined data are handled (if it is), not how it would handle those field names
I'll look into this but I do not think this happened with other related tables in this geodatabase. Outside of ESRI products, ER tables are not an issue wrt exporting data.
I did create a copy to the geodatabase and the tool worked. I do not remember the difference between the table types? Why a copy is exported and a table query is not but it must be a nuance I should have remembered.
I was able to get around a table to Excel error I was receiving in ArcGIS Pro 3.3.1. My workaround was to export my table to an .xls file instead of an .xlsx file. I hope this helps someone else.