Troubles Importing XTools Pro Tools In Python

4545
7
Jump to solution
01-29-2014 03:15 PM
GeorgeHaskett
Occasional Contributor III
Okay,

I have tried a few options based upon what I could find online, however I am still getting errors when I try to import and run an XTools Pro tool in python.  Everything works fine when I run it as a python script attached to a model in model builder or simply run it directly as a stand alone python script in ArcGIS Desktop.

Yes, it is licensed, etc.

Here is the code I am currently trying:

xlsxPath = reportFolder+"earthquakeReport.xlsx" xlsxDatedReport = reportFolderDated+"earthquakeReport_{}.xlsx".format(datetime.strftime(datetime.now(),"%Y-%m-%d_%H%M")) xList = "DATE;MAGNITUDE;EPICENTER"  arcpy.ImportToolbox("C:/Program Files (x86)/DataEast/XTools Pro/Toolbox/XTools Pro.tbx")  arcpy.gp.XToolsGP_Export2Excel(eqPoliciesFC,xList,xlsxPath) # error = "pythonw.exe has stopped working"  arcpy.XToolsPro_Export2Excel(eqPoliciesFC,xList,xlsxPath) # error = <type 'exceptions.AttributeError'>: 'module' object has no attribute 'XToolsPro_Export2Excel'



I have also dragged the Export2Excel tool into a model and export it resulting in the following code:

# Import arcpy module import arcpy  # Load required toolboxes arcpy.ImportToolbox("C:/Program Files (x86)/DataEast/XTools Pro/Toolbox/XTools Pro.tbx")  # Local variables: eqPolicies = "C:\\arcgisserver\\gisData\\services\\eqMap\\data\\eqMap.gdb\\eqPolicies" excelTest_xlsx = "C:\\arcgisserver\\gisData\\services\\eqMap\\data\\excelTest.xlsx"  # Process: Export Table to MS Excel arcpy.gp.toolbox = "C:/Program Files (x86)/DataEast/XTools Pro/Toolbox/XTools Pro.tbx"; arcpy.XToolsGP_Export2Excel_eqMapAnalysis(eqPolicies, "DATE;MAGNITUDE;EPICENTER", excelTest_xlsx, "true")



Any suggestions?
Any chance this is a 32 vs 64 bit issue?

I am using ArcGIS 10.2.

Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi George,

Since you are using 10.2, can you use the new Table to Excel tool instead of using XTools?

View solution in original post

0 Kudos
7 Replies
JakeSkinner
Esri Esteemed Contributor
Hi George,

Since you are using 10.2, can you use the new Table to Excel tool instead of using XTools?
0 Kudos
GeorgeHaskett
Occasional Contributor III
Jake,

I could, but I was hoping to only export approx. 10 out of some 20+ fields.  The esri tool seems limited, however I guess I could add a few more steps and create a copy of the data, then remove the unwanted fields, and then export the table.

It appears that one could alter the names of the fields, but can they select only a few fields to export in the new Table to Excel tool?

Unfortunately for a new tool they are seriously lacking in reference material...

I may give it a try while I am attempting to get the XTools working.

Thanks
0 Kudos
LucasDanzinger
Esri Frequent Contributor
You could make a table view first, and filter the fields, similar to Example 2 in the help.
0 Kudos
curtvprice
MVP Esteemed Contributor
I get yet another error when I try this at the Desktop python prompt:

>>> arcpy.XToolsGP_Export2Excel(r'D:\Users\cprice\outWorkspaceTable.dbf',"TABLE_ID", "test.xlsx")
Runtime error  Traceback (most recent call last):   File "<string>", line 1, in <module>   File "C:\Program Files (x86)\DataEast\XTools Pro\Toolbox\XTools Pro.tbx", line 754, in XToolsGP_Export2Excel ExecuteError: Failed to execute. Parameters are not valid. ERROR 000816: The tool is not valid. Failed to execute (XToolsGP_Export2Excel).  
0 Kudos
by Anonymous User
Not applicable
I made this tool about 6 months ago.  It works pretty nicely to export tables to excel.  There is also an option to exclude fields.  See attached toolbox.

Here is a view of the checkbox for excluding the fields:

[ATTACH=CONFIG]30998[/ATTACH]

And here is the toolbox:
0 Kudos
GeorgeHaskett
Occasional Contributor III
I made this tool about 6 months ago.  It works pretty nicely to export tables to excel.  There is also an option to exclude fields.  See attached toolbox.

Here is a view of the checkbox for excluding the fields:

[ATTACH=CONFIG]30998[/ATTACH]

And here is the toolbox:


Nice work, the script looks pretty clean.  If I were to use it I would most likely modify it to work directly via python with fixed variables.  It looks like it will be a great addition to my toolbox.  Gave it a test run, but it appears that I don't have the openpyxl files.  I'll have to download them and try it again later.

I opted to add a few more lines of code in python using some additional arcpy tools.  When I get a chance I will try to get the openpyxl up and running so I can try the tool out.

Thanks again.
0 Kudos
by Anonymous User
Not applicable

Gave it a test run, but it appears that I don't have the openpyxl files.


I attached the openpyxl files in the folder (inside the "mods" subdirectory).  I am not sure if it is for version 2.6 or 2.7.  I guess my attempt to append the mods folder to your PYTHONPATH failed.  If you copy the openpyx folder into a directory in your PYTHONPATH, you should be able to run that tool.  I would just throw it in the site-packages folder.  I'm running ArcGIS 10.0 and python 2.6 so my site packages is here:

C:\Python26\ArcGIS10.0\Lib\site-packages

My script doesn't handle domains like the Esri tool, but it works well for a quick and dirty export.  I also included some options to center the cells and shade every other row in a light gray.  I haven't had any problems with it yet.
0 Kudos