>>> arcpy.mapping.ExportReport('2013pp',"C:\reports\2013_Graffiti.rlf","C:\reports\2013_Graffiti_report.pdf") Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_ return fn(*args, **kw) File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\mapping.py", line 506, in ExportReport assert isinstance(report_source, (MapDocument, TableView, Layer)), str(type(report_source)) AssertionError: <type 'str'>
Parsing error SyntaxError: invalid syntax (line 1)
mxd = arcpy.mapping.MapDocument('current') df = arcpy.mapping.ListDataFrames(mxd, 'Layers') layer = arcpy.mapping.ListLayers(df, '2013pp') arcpy.mapping.ExportReport(layer,"C:\reports\2013_Graffiti.rlf","C:\reports\2013_Graffiti_report.pdf")
Did you ever find a solution to this problem? I'm using 10.3 but getting the same thing:
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "N:/13057/13057.3/Production/InspectionOnCall/Testing/PDF Generation Testing.py", line 14, in <module> generateReports("VPS-030") File "N:/13057/13057.3/Production/InspectionOnCall/Testing/PDF Generation Testing.py", line 12, in generateReports arcpy.mapping.ExportReport(inTable, template, "workOrder" + str(workOrderID) + ".pdf", "DEFINITION_QUERY", "Baltimore County DPW Bureau of Utilies On-call Contract Management", report_definition_query="SELECT * FROM tbl_Asset_Tracking WHERE WorkOrder = " + str(workOrderID)) File "c:\program files\arcgis\desktop10.3\arcpy\arcpy\utils.py", line 182, in fn_ return fn(*args, **kw) File "c:\program files\arcgis\desktop10.3\arcpy\arcpy\mapping.py", line 532, 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)) RuntimeError: Error in generating report
Apologies upfront. Being over a year ago, I can't recall exactly what was done to resolve this. I did learn that ExportReport will not support background processing and it did not seems to like being a part of a stand alone Python script either. I was able to execute this funtion by turning off background processing and running the script via a ArcMap Script Tool.
Thanks, this did the trick for me as well. Not sure though why this function works better within an ArcMap environment rather then running as a standalone script.
Thanks for the help.
lyr = arcpy.mapping.Layer("<path>")
Is <path> a table or feature class? If so this won't work, you need to create a layer object.
report_src in arcpy.ExportReport() can be reference to layer file or a table view. I am utilizing the former in this example.