Export Report To Excel (Data Management)

Summary

Exports an ArcGIS AllSource 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 AllSource 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 sectionsAll report sections will be exported to an individual sheet. This is the default.
  • One sheet for each subreportEach subreport will be exported to an individual sheet.
  • One sheet for each report pageEach 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 pagesAll pages will be exported. This is the default.
  • Last pageOnly the last page will be exported.
  • Odd numbered pagesOnly the odd numbered pages will be exported.
  • Even numbered pagesOnly the even numbered pages will be exported.
  • Custom page rangeA 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_HEIGHTThe row height will collapse or expand to fit the content of the cell. This is the default.
  • NO_ADJUST_ROW_HEIGHTThe 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_CELLSThe cells of the Excel file will be merged to fit the content. This is the default.
  • NO_MERGE_CELLSThe 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_WHITESPACEExtra white space will be removed from the output Excel file. This is the default.
  • NO_REMOVE_WHITESPACEExtra 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_GRIDLINESGrid lines will be automatically displayed when viewing sheets in the output Excel file. This is the default.
  • NO_DISPLAY_GRIDLINESGrid 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_TEXTUnsupported numeric formats will be exported as text.
  • RAW_VALUEUnsupported 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.

  • ALLAll report sections will be exported to an individual sheet. This is the default.
  • SUBREPORTEach subreport will be exported to an individual sheet.
  • PAGEEach report page will be exported to an individual sheet.
String
page_range_type
(Optional)

Specifies the page range of the report that will exported.

  • ALLAll pages will be exported. This is the default.
  • LASTOnly the last page only will be exported.
  • ODDOnly odd numbered pages will be exported.
  • EVENOnly even numbered pages will be exported.
  • CUSTOMA 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.

Related topics