Report#

class ansys.dynamicreporting.core.Report(service=None, report_name='default', report_obj=None)#

Bases: object

Provides for generating the Report object for the database.

Parameters:
serviceansys.dynamicreporting.core.Service, optional

Ansys Dynamic Reporting object that provides the connection to the database. The default is None.

report_namestr, optional

Name of the report object in the database. The default is default.

report_objstr, optional

TemplateREST object from low-level ADR API. Do not modify.

Methods

Report.export_html([directory_name, ...])

Export report as static HTML.

Report.export_json(json_file_path)

Export this report to a JSON-formatted file.

Report.export_pdf([file_name, query_params, ...])

Export report as PDF.

Report.get_guid()

Get the guid corresponding to the report.

Report.get_iframe([width, height, filter, ...])

Get the iframe object corresponding to the report.

Report.get_report_component([prefix, ...])

A HTML code of the web component for report fetching.

Report.get_report_script()

A block of JavaScript script to define the web component for report fetching.

Report.get_url([filter, item_filter])

Get the URL corresponding to the report.

Report.visualize([new_tab, filter, item_filter])

Render the report.

export_html(directory_name: str = '', query_params: dict | None = None, item_filter: str | None = None, filename: str | None = 'index.html', no_inline_files: bool | None = False) bool#

Export report as static HTML.

Parameters:
directory_namestr

Path for the HTML export directory

query_paramsdict, optional

Dictionary for parameters to apply to report template. Default: None

item_filter: str, optional

String corresponding to query to run on the database items before rendering the report. Default: None

filenamestr, optional

Filename for the exported static HTML file. Default: index.html

no_inline_filesbool, optional

If True, the information is exported as stand alone files instead of in line content in the static HTML. Default: False

Returns:
bool

Success status of the HTML export: True if it worked, False otherwise

Examples

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = "My Top Report")
succ = my_report.export_html(directory_name = r'D:\tmp', query_params={"colormode": "dark"})
succ2 = my_report.export_html(filename=r'D:\tmp\onlyimages.pdf', item_filter = 'A|i_type|cont|image;')
export_json(json_file_path: str) None#

Export this report to a JSON-formatted file.

Parameters:
json_file_pathstr

Path of the JSON file to be exported to.

Returns:
None.

Examples

import ansys.dynamicreporting.core as adr

adr_service = adr.Service(ansys_installation=r'C:\Program Files\ANSYS Inc\v232')
adr_service.connect(url='http://localhost:8020', username = "admin", password = "mypassword")
report = adr_service.get_report(report_name="my_report_name")
report.export_json(r'C:\tmp\my_json_file.json')
export_pdf(file_name: str = '', query_params: dict | None = None, item_filter: str | None = None, page: list | None = None, delay: int | None = None) bool#

Export report as PDF. Currently works only with a local ADR installation, and not a docker image.

Parameters:
file_namestr

Path and filename for the PDF file to export.

query_paramsdict, optional

Dictionary for parameters to apply to report template. Default: None

item_filter: str, optional

String corresponding to query to run on the database items before rendering the report. Default: None

pagelist, optional

List of integers that represents the size of the exported pdf. Default: None, which corresponds to A4 size

delayint, optional

Seconds to delay the start of the pdf export operation. Default: None, which corresponds to no delay

Returns:
bool

Success status of the PDF export: True if it worked, False otherwise

Examples

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = "My Top Report")
succ = my_report.export_pdf(file_name=r'D:\tmp\myreport.pdf', query_params = {"colormode": "dark"})
succ2 = my_report.export_pdf(filename=r'D:\tmp\onlyimages.pdf', item_filter = 'A|i_type|cont|image;')
get_guid() str#

Get the guid corresponding to the report.

Returns:
str

guid corresponding to the report. If no guid exists, an empty string is returned.

Examples

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = 'Top report')
report_url = my_report.get_guid()
get_iframe(width: int = 1000, height: int = 800, filter: str = '', item_filter: str = '')#

Get the iframe object corresponding to the report.

Parameters:
widthint, optional

Width of the iframe object. The default is 1000.

heightint, optional

Height of the iframe object. The default is 800.

filterstr, optional

DEPRECATED. Use item_filter instead. Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

item_filterstr, optional

Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

Returns:
iframe

iframe object corresponding to the report. If no iframe can be generated, None is returned.

Examples

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = "My Top Report")
report_iframe = my_report.get_iframe()
get_report_component(prefix: str = '', filter: str = '', style_path: str = '', width: int = 1000, height: int = 800, item_filter: str = '') str#

A HTML code of the web component for report fetching. By default, the web component uses iframe to embed the report. If users have provided additional configuration settings on their application server or on another proxy server, the web component will use fetch API to embed the report directly in the application.

Note

This feature has been deprecated as of 2025 R., Refer to the adr_offline_report_src.js file in the django/utils/remote/adr_offline_report_src/ directory, from the latest ADR installation. The new web component <adr-offline-report></adr-offline-report> supports report embed and style overwrites generated from both server and serverless ADR.

Parameters:
prefixstr, optional

A user defined key in the server to reroute and fetch the report from ADR server. If not provided, the web component will use the default iframe to embed the report in the application.

filterstr, optional

DEPRECATED: use item_filter instead. Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

item_filterstr, optional

Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

style_path: str, optional

The hosting app’s stylesheet path. The default is "". The syntax is used to overwrite report styling using an external CSS file.

widthint, optional

Width of the iframe if the web component uses <iframe> to embed report. The default is 1000.

heightint, optional

Height of the iframe if the web component uses <iframe> to embed report. The default is 800.

Returns:
str

The web component HTML code (as string) that will get embedded in the HTML page

Examples

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = 'Top report')
my_report.get_report_component()
get_report_script() str#

A block of JavaScript script to define the web component for report fetching. Note that the function return a block of string that stands for JavaScript codes and need to be wrapped in a <script>…</script> HTML tag.

Note

This feature has been deprecated as of 2025 R2. Refer to the adr_offline_report_src.js file in the django/utils/remote/adr_offline_report_src/ directory, from the latest ADR installation. The new web component <adr-offline-report></adr-offline-report> supports report embed and style overwrites generated from both server and serverless ADR.

Returns:
str

JavaScript code to define the report fetching web component (as a block of string) that will get embedded in the HTML page

Examples

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = 'Top report')
my_report.get_report_script()
get_url(filter: str = '', item_filter: str = '') str#

Get the URL corresponding to the report.

Parameters:
filterstr, optional

DEPRECATED. Use item_filter instead. Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

item_filterstr, optional

Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

Returns:
str

URL corresponding to the report. If no URL exists, an empty string is returned.

Examples

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = 'Top report')
report_url = my_report.get_url()
visualize(new_tab: bool = False, filter: str = '', item_filter: str = '') None#

Render the report.

Parameters:
new_tabbool, optional

Whether to render the report in a new tab if the current environment is a Jupyter notebook. The default is False, in which case the report is rendered in the current location. If the environment is not a Jupyter notebook, the report is always rendered in a new tab.

filterstr, optional

DEPRECATED. Use item_filter instead. Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

item_filterstr, optional

Query string for filtering. The default is "". The syntax corresponds to the syntax for Ansys Dynamic Reporting. For more information, see _Query Expressions in the documentation for Ansys Dynamic Reporting.

Returns:
Report

Rendered report.

Examples

Render a report in a new tab.

import ansys.dynamicreporting.core as adr
adr_service = adr.Service(ansys_installation = r'C:\Program Files\ANSYS Inc\v232')
ret = adr_service.connect()
my_report = adr_service.get_report(report_name = "My First Report")
my_report.visualize(new_tab = True)