Hello
I wonder if someone can help me please.
I have a feature class which I want to export each record individually into a report (see attached) and then export the report into excel. Each of the reports generated will be in the same format but need to be placed into separate excel spreadsheets.
This is the script I have created:
# Import arcpy module
import arcpy
# Local variables:
Wells = "Wells"
# Process: Select Layer By Attribute
mxd = arcpy.mapping.MapDocument(r"C:\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[0]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells.xls")
mxd = arcpy.mapping.MapDocument(r"C:\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[0]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells2.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells2.xls")
mxd = arcpy.mapping.MapDocument(r"C:\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[0]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells3.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells3.xls")
mxd = arcpy.mapping.MapDocument(r"C:\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[0]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells4.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells4.xls")
del mxd
However, when I run the script I get the following error message:
Executing: Script2
Start Time: Mon Dec 09 12:26:51 2013
Running script Script2...
Traceback (most recent call last):
File "C:\New_script.py", line 15, in <module>
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells.xls")
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\mapping.py", line 515, in ExportReport
return report_source._arc_object.ExportReport(*gp_fixargs((report_layout_file, output_file, dataset_option, report_title, starting_page_number, page_range, report_definition_query, extent, field_map), True))
IOError: Could not open report template
Failed to execute (Script2).
Failed at Mon Dec 09 12:26:51 2013 (Elapsed Time: 0.19 seconds)
I hope someone can help me please.
Thanks