Export ESRI table to Excel


Its fairly common for users to take tables in file geodatabases, personal geodatabases, coverages, shapefiles etc and convert them into excel.  The purpose of this page is to demonstrate a simple export python script which has been assembled and how you might make use of it.

3-31-2011 - Updated the script to provide some addtional functionality.  The "How it Works" section has been updated to reflect these changes.  New things you can do include:
  • overwrite an existing worksheet in a spreadsheet
  • Automatically calculate a new spreadsheet name if the name of the spreadsheet you supplied already exists.

How it Works:

Step 1:
If you are not with the BC government then download the script HERE (updated link 3/2/2011!)
You will also need to download my xl_func.py module. (link on xl_funcs.py text should take you there!)

If you are with the BC government you should find copies of the script in the script warehouse. (
P:\corp\script_whse\python\Utility_Misc\Ready\xlutils OR \\giswhse\whse_np\corp\script_whse\python\Utility_Misc\Ready\xlutils)

Step 2:
Once downloaded either stick them in the same directory as the script that is going to be calling their functionality or in a path that is contained in your PYTHONPATH environment variable.

Step 3:
Create a new python script, Define the following parameters in your script:
  1. The name of an excel workbook you would like to create or add to.
  2. The name of an ESRI table you would like to export to an excel table
  3. Create a gp (Geoprocessing) object
Call the functionality of the script!  The following example shows a simple script that exports a filegeodatabase table to an excel table.


import arcgisscripting
import export2Excel_v2

# This creates an arcgis 9.3 gp object but any gp
# object will do.
gp = arcgisscripting.create(9.3)
esriTable = r'R:\crownSales\lots.gdb\lotTable'
excelTab = r'R:\crownSales\report.xlsx'

# new create an excel export object, and send it
# 1 - your gp object
# 2 - the name of the esri table
# 3 - the name of the excel table to create
excelExpObj = export2Excel_v1.excelExport(gp,
esriTable , excelTab)

# finally perform the export!
# doExport method can take 2 option args:
#    1) name of the worksheet you want to export to.  If you do not enter
#       this value the ss that is going to get created will be called:
#       "ESRI Exp"
#    2) whether you want to overwrite the ss or not.  This is a boolean
#       value.  It this value is true and the ss exists it will get deleted
#       and then recreated.
#       if you set this to be false and the ss already exists the app will 
#       add a number to your ss name to make it unique, and create a ss
#       with that name.
# the example below uses the defaults which resolves to 
#  ss being created = ESRI Exp
#  if the ss exists the script will create one called "ESRI Exp1"

# If you want to export additional ss then call the method below.
# it takes 3 args:
#  a) esri table to export
#  b) the name of the worksheet to dump the data to.
#  c) whether to delete the ss if it already exists (boolean, default
#     value is False.
excelExpObj.export2NewSheet(esriTable, 'nameOfWorksheet')

# That's it!

Kevin Netherton,
Nov 3, 2010, 12:24 PM
Kevin Netherton,
Mar 31, 2011, 1:50 PM
Kevin Netherton,
Sep 24, 2012, 10:43 AM
Kevin Netherton,
Nov 3, 2010, 12:25 PM