Label | Explanation | Data 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.
| Boolean |
Merge Cells
(Optional) | Specifies whether the cells of the Excel file will be merged to fit the content.
| Boolean |
Remove Vertical Whitespace (Optional) | Specifies whether extra white space will 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.
| Boolean |
Export Unsupported Numeric Formats as Text (Optional) | Specifies whether unsupported numeric formats will be exported as text.
| Boolean |
Sheet Export (Optional) | Specifies how each report will be exported to sheets.
| String |
Page Range Type
(Optional) | Specifies the page range of the report that will be exported.
| 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 |
Summary
Exports an ArcGIS AllSource report or a report file to a Microsoft Excel file (.xlsx).
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
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})
Name | Explanation | Data 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.
| Boolean |
merge_cells (Optional) | Specifies whether the cells of the Excel file will be merged to fit the content.
| Boolean |
remove_vertical_whitespace (Optional) | Specifies whether extra white space will 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.
| Boolean |
export_unsupported_formats_as_text (Optional) | Specifies whether unsupported numeric formats will be exported as text.
| Boolean |
sheet_export (Optional) | Specifies how each report will be exported to sheets.
| String |
page_range_type (Optional) | Specifies the page range of the report that will exported.
| 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
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