Export Report To Excel (Data Management)

Summary

Exports an ArcGIS Pro report or a report file to a Microsoft Excel file (.xlsx).

Learn more about reports

Usage

  • This tool creates an Excel file from a report in an ArcGIS Pro project or a report file (.rptx).

  • If a query exists in the report or report file definition, additional expressions will be appended to the existing query.

  • This tool supports page range settings to export certain pages in addition to the entire report.

  • This tool supports custom page numbering options to modify start and total page numbers.

  • This tool supports exporting report sections across multiple sheets.

  • This tool does not support exporting image elements, attachments, map frames, chart frames, or supplemental pages. This tool exports text and graphics.

Parameters

LabelExplanationData Type
Input Report

The input report or .rptx file.

Report; File
Excel File

The output Excel file.

File
Expression
(Optional)

An SQL expression that will be used to select a subset of records. This expression will be applied in addition to any existing expressions.

SQL Expression
Adjust Row Height
(Optional)

Specifies whether the row height will adjust to fit the content of the cell.

  • Checked—The row height will collapse or expand to fit the content of the cell. This is the default.
  • Unchecked—The row height will not collapse or expand to fit the content of the cell.

Boolean
Merge Cells
(Optional)

Specifies whether the cells of the Excel file will be merged to fit the content.

  • Checked—The cells of the Excel file will be merged to fit the content. This is the default.
  • Unchecked—The cells of the Excel file will not be merged to fit the content.

Boolean
Remove Vertical Whitespace
(Optional)

Specifies whether extra white space will be removed from the output Excel file.

  • Checked—Extra white space will be removed from the output Excel file. This is the default.
  • Unchecked—Extra white space will not be removed from the output Excel file.

Boolean
Display Gridlines
(Optional)

Specifies whether grid lines will be automatically displayed when viewing sheets in the output Excel file.

  • Checked—Grid lines will be automatically displayed when viewing sheets in the output Excel file. This is the default.
  • Unchecked—Grid lines will not be displayed when viewing sheets in the output Excel file.

Boolean
Export Unsupported Numeric Formats as Text
(Optional)

Specifies whether unsupported numeric formats will be exported as text.

  • Checked—Unsupported numeric formats will be exported as text.
  • Unchecked—Unsupported numeric formats will be exported as a general Excel data type. This is the default.

Boolean
Sheet Export
(Optional)

Specifies how each report will be exported to sheets.

  • One sheet for all report sections—All report sections will be exported to an individual sheet. This is the default.
  • One sheet for each subreport—Each subreport will be exported to an individual sheet.
  • One sheet for each report page—Each report page will be exported to an individual sheet.
String
Page Range Type
(Optional)

Specifies the page range of the report that will be exported.

  • All pages—All pages will be exported. This is the default.
  • Last page—Only the last page will be exported.
  • Odd numbered pages—Only the odd numbered pages will be exported.
  • Even numbered pages—Only the even numbered pages will be exported.
  • Custom page range—A custom page range will be exported using the Custom Page Range parameter value.
String
Custom Page Range
(Optional)

The pages that will be exported when the Page Range Type parameter is set to Custom page range. You can set individual pages, ranges, or a combination of both separated by commas, such as 1, 3-5, 10.

String
Initial Page Number
(Optional)

The initial page number of the report that will be used to create a page numbering offset to add more pages to the beginning of the report.

Long
Final Page Number
(Optional)

The page number that will be displayed on the last page of the Excel file.

Long

arcpy.management.ExportReportToExcel(in_report, out_xlsx_file, {expression}, {adjust_row_height}, {merge_cells}, {remove_vertical_whitespace}, {display_gridlines}, {export_unsupported_formats_as_text}, {sheet_export}, {page_range_type}, {custom_page_range}, {initial_page_number}, {final_page_number})
NameExplanationData Type
in_report

The input report or .rptx file.

Report; File
out_xlsx_file

The output Excel file.

File
expression
(Optional)

An SQL expression that will be used to select a subset of records. This expression will be applied in addition to any existing expressions.

SQL Expression
adjust_row_height
(Optional)

Specifies whether the row height will adjust to fit the content of the cell.

  • ADJUST_ROW_HEIGHT—The row height will collapse or expand to fit the content of the cell. This is the default.
  • NO_ADJUST_ROW_HEIGHT—The row height will not collapse or expand to fit the content of the cell.
Boolean
merge_cells
(Optional)

Specifies whether the cells of the Excel file will be merged to fit the content.

  • MERGE_CELLS—The cells of the Excel file will be merged to fit the content. This is the default.
  • NO_MERGE_CELLS—The cells of the Excel file will not be merged to fit the content.
Boolean
remove_vertical_whitespace
(Optional)

Specifies whether extra white space will be removed from the output Excel file.

  • REMOVE_WHITESPACE—Extra white space will be removed from the output Excel file. This is the default.
  • NO_REMOVE_WHITESPACE—Extra white space will not be removed from the output Excel file.
Boolean
display_gridlines
(Optional)

Specifies whether grid lines will be automatically displayed when viewing sheets in the output Excel file.

  • DISPLAY_GRIDLINES—Grid lines will be automatically displayed when viewing sheets in the output Excel file. This is the default.
  • NO_DISPLAY_GRIDLINES—Grid lines will not be displayed when viewing sheets in the output Excel file.
Boolean
export_unsupported_formats_as_text
(Optional)

Specifies whether unsupported numeric formats will be exported as text.

  • VALUE_AS_TEXT—Unsupported numeric formats will be exported as text.
  • RAW_VALUE—Unsupported numeric formats will be exported as a general Excel data type. This is the default.
Boolean
sheet_export
(Optional)

Specifies how each report will be exported to sheets.

  • ALL—All report sections will be exported to an individual sheet. This is the default.
  • SUBREPORT—Each subreport will be exported to an individual sheet.
  • PAGE—Each report page will be exported to an individual sheet.
String
page_range_type
(Optional)

Specifies the page range of the report that will exported.

  • ALL—All pages will be exported. This is the default.
  • LAST—Only the last page only will be exported.
  • ODD—Only odd numbered pages will be exported.
  • EVEN—Only even numbered pages will be exported.
  • CUSTOM—A custom page range will be exported using the custom_page_range parameter value.
String
custom_page_range
(Optional)

The pages that will be exported when the page_range_type parameter is set to CUSTOM. You can set individual pages, ranges, or a combination of both separated by commas, such as 1, 3-5, 10.

String
initial_page_number
(Optional)

The initial page number of the report that will be used to create a page numbering offset to add more pages to the beginning of the report.

Long
final_page_number
(Optional)

The page number that will be displayed on the last page of the Excel file.

Long

Code sample

ExportReporttoExcel example (Python window)

The following script exports a report to an .xlsx file.

a = arcpy.mp.ArcGISProject('current')
r = a.listReports('Sites')[0] # Find the report
arcpy.management.ExportReportToExcel(r, r"C:\temp\SiteList.xlsx") # Export report to xlsx

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics