Export to Excel using Model Builder

4046
2
01-25-2012 10:39 PM
boninoenrico
New Contributor
Hello,

I've calculated some indicators values (for wetland evolution analysis), using the Model Builder system.
The results are saved as .dbf file (or as an attribute table linked to polygon features).

I'm wondering if:
1) it is possible to export directly from ArcGis to Excel using Model Builder (select a tool and automatically open Excel with the .dbf selected)
2) show on screen the .dbf created at the end o the processing, without to go in the source tab in the TOC and select manually the .dbf file

Thanks a lot for any help and suggestion

Enrico Bonino
0 Kudos
2 Replies
DuncanHornby
MVP Notable Contributor
Enrico,

I think the short answer is no to both of your questions.

Duncan
0 Kudos
curtvprice
MVP Esteemed Contributor
1) it is possible to export directly from ArcGis to Excel using Model Builder (select a tool and automatically open Excel with the .dbf selected)


Normally .dbf are associated with .dbf files by the MS Office installation, so you should be able to do this with the Calculate Value tool, using Python and the Windows "start" command to launch the file as if you had double-clicked it in Windows Explorer.

Be sure you have the the .dbf (element "output_dbf") be a precondition so it will launch after the .dbf is created
The syntax below r, double quotes, model element name in percents, double quotes) is critical so python gets the path unmodified by parsing.

Calculate Value tool arguments:

Expression:

launch(r"%output_dbf%")


Code block:

def launch(path):
    import os
    dir = os.path.dirname(path)
    file = os.path.basename(path)
    os.system("start /d \"%s\" %s" % (dir,file))


If the file is open in ArcGIS and Excel at the same time, you will likely run into file locking issues and will have to close either one or the other to write to the file. You have been warned!
0 Kudos