ExportReport problem - ArcMap 10.8.1

02-10-2022 08:04 AM
Occasional Contributor II

I need some real help.  I have recently upgraded from ArcMap 10.6.1 to 10.8.1.  The script worked in 10.6.1 but post upgrade it no longer works.  I have tried to break down the script but no such luck.  Here is what I have tried.

  1. recreate lyr file
  2. recreate rlf file
  3. tried referenceing mxd vs layer file
  4. run in foreground only.

Nothing has lead to success. If I run my code in ArcMap it runs successful but not in pyscripter or pythonIDE.



import arcpy

arcpy.env.overwriteOutput = True

fc = arcpy.mapping.Layer(r'E:\GIS\Data\GIS\Dept\CommDev\HistoricPreservation\Inventory\HistoricInventory.lyr')
fields = ['OBJECTID', 'propkey', 'curraddress']

# For each row, print the WELL_ID and WELL_TYPE fields, and
# the feature's x,y coordinates
with arcpy.da.SearchCursor(fc, fields) as cursor:
    for row in cursor:
        print(u'{0}, {1}, {2}'.format(row[0], row[1], row[2]))

output = r'E:\GIS\Data\GIS\Dept\CommDev\HistoricPreservation\Inventory\Report.pdf'
rlf = r'E:\GIS\Data\GIS\Dept\CommDev\HistoricPreservation\Inventory\HistoricInventory_ReportLayout.rlf'




Here is what was returned.  


*** Remote Interpreter Reinitialized ***
100, 312020900, 315 W PROSPECT AV
Traceback (most recent call last):
  File "<module1>", line 26, in <module>
  File "C:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy\arcpy\utils.py", line 182, in fn_
    return fn(*args, **kw)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.8\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


@XanderBakker and @ManishPatel , I have seen you two post on this content before.  Perhaps one of you might be able to help me with this.



Tags (3)
0 Kudos
2 Replies
Esri Esteemed Contributor

Hi @HeathAnderson ,

I must admit that I haven't touched ArcMap in over 2 years now, and there is no way I can validate the code, but let me see if we can get to the bottom of this. 

I assume that if you manually execute the report layout in ArcMap 10.8.1, it works, right?

Checking the documentation I don't see a difference in the export tool between 10.6.x and 10.8.x. Please check that the root to the input layerfiles, the input report layout and the output pdf file are all valid and the layer can be added to ArcMap without problems and the report layout can be loaded into ArcMap. 

There is nothing wrong with your code as far as I can tell.


0 Kudos
Occasional Contributor II

Hi Xander,

Yeah, I attempted to recreate this report in Pro however, Pro doesn't offer a grow/shrink property when you insert an attribute.  I really need the grow/shrink option to be avaiable in Pro if I am ever to move this report out of ArcMap.  

But to answer your questions; yes, I have checked both the report file and layer file.  Both are valid and the I can see the feature when i add the layer file to an arcmap session.

If I open an ArcMap session and run the report in model builder it works fine.



0 Kudos