ReportSection

Zusammenfassung

The ReportSection object references a report section in a report. It provides access to common properties such as a definition query and a method to set the reference data source.

Diskussion

An ArcGIS Pro report can contain multiple report sections. Report sections are accessed using the listSections method on the Report object. This returns a Python list of ReportSection and ReportLayoutSection objects. Each report section can be referenced by a unique name and has a REPORT_SECTION type.

A ReportSection has a data source that can be identified using the referenceDataSource property. To change the data source, use the setReferenceDataSource method. This method maps the fields from the new data source to the fields of the report that were defined by the original data source. The field names, not the field aliases, must be an exact, case-sensitive match.

To filter the records exported to PDF, modify the report section's definitionQuery property. To exclude a report section from the exported PDF, set the visible property to false.

Eigenschaften

EigenschaftErläuterungDatentyp
definitionQuery
(Lesen und schreiben)

The definition query of the first ReportSection. Use this to filter the records exported to PDF.

String
metadata
(Lesen und schreiben)

Get or set the report's Metadata class information. Note that setting metadata is dependent on the isReadOnly property value.

Metadata
name
(Lesen und schreiben)

The report's name. It is important that all reports in a project have a unique name so they can be easily referenced by name.

String
referenceDataSource
(Schreibgeschützt)

The reference data source connection information of the first ReportSection.

Dictionary

Methodenübersicht

MethodeErläuterung
setReferenceDataSource (data_source)

Sets a report section's reference data source.

Methoden

setReferenceDataSource (data_source)
ParameterErläuterungDatentyp
data_source

The data reference for the report section. This parameter can be a Layer object, a Table object, or a string that represents the path to an external data source.

(Der Standardwert ist None)

Object

The setReferenceDataSource method sets the data source that the report section references using a Layer object, a Table object, or a string that represents the path to an external data source.

Codebeispiel

ReportSection example 1

The following script gets all report sections in a report:

aprx = arcpy.mp.ArcGISProject(r"C:\DemoData\NationalParks.aprx")
report = aprx.listReports("National Parks Report")[0]
sections = [s.name for s in report.listSections() if s.type=="REPORT_SECTION"] # Get list of report section names
for s in sections:
	print(s)
# National Parks Overview
# Park Highlights
# Annual Review
ReportSection example 2

The following script sets a report section visibility to False:

aprx = arcpy.mp.ArcGISProject(r"C:\DemoData\NationalParks.aprx")
report = aprx.listReports("National Parks Report")[0]
section = report.listSections("National Parks Overview")[0] # Find the report section by name
section.visible = False
ReportSection example 3

The following script sets the reference data source for the second report section in a report to a table in a map:

aprx = arcpy.mp.ArcGISProject(r"C:\DemoData\NationalParks.aprx")
map = aprx.listMaps("National Parks")[0]  # Find a map in the project
table = map.listTables()[0] # Find the first table in the map
report = aprx.listReports("National Parks Report")[0]
section = report.listSections()[1] # Find the report section by index
section.setReferenceDataSource(table)
ReportSection example 4

The following script modifies the definition query for the third report section in a report:

aprx = arcpy.mp.ArcGISProject(r"C:\DemoData\NationalParks.aprx")
report = aprx.listReports("National Parks Report")[0]
section = report.listSections("Annual Review")[0] # Find the report section by name
section.definitionQuery = "ParkName = 'Yosemite'"