Exporting a Report From Code
The reporting tool allows you to export the generated report or dashboard to various formats. Below is a list of all available export formats for reports and dashboards:
Name |
Reports |
Dashboards |
Document (Snapshot) |
+ |
+ |
Adobe PDF |
+ |
+ |
Microsoft XPS |
+ |
- |
Microsoft PowerPoint (.pptx) |
+ |
- |
HTML |
+ |
+ |
HTML5 |
+ |
- |
Text |
+ |
- |
Microsoft Word (.docx) |
+ |
- |
Microsoft Excel (.xlsx) |
+ |
+ |
OpenDocument Writer (.odt) |
+ |
- |
OpenDocument Calc (.ods) |
+ |
- |
Comma Separated Value (.csv) |
+ |
+ |
Scalable Vector Graphics (.svg) |
+ |
+ |
To export a report, you should utilize the special exportDocument() function on the report object.
app.py |
from stimulsoft_reports.report import StiReport from stimulsoft_reports.report.enums import StiExportFormat
report = StiReport() report.loadFile(url_for('static', filename='reports/SimpleList.mrt')) report.render() report.exportDocument(StiExportFormat.PDF)
|
Information |
Exporting a report does not automatically trigger its construction. Therefore, the loaded report template must first call the render() function, which initiates the pre-building of the report. For generated reports, calling the specified function is not necessary.
|
As arguments to the exportDocument() function, you should specify the required export format from the StiExportFormat enumeration. The available format options are as follows:
Name |
Description |
StiExportFormat.DOCUMENT |
Saves the rendered document. |
StiExportFormat.PDF |
Saves to Adobe PDF. |
StiExportFormat.XPS |
Saves to XPS (XML Paper Specification). |
StiExportFormat.POWERPOINT |
Saves to Microsoft PowerPoint. |
StiExportFormat.HTML |
Saves to HTML. |
StiExportFormat.HTML5 |
Saves to HTML5, using SVG markup elements. |
StiExportFormat.TEXT |
Saves to text. |
StiExportFormat.WORD |
Saves to Microsoft Word. |
StiExportFormat.EXCEL |
Saves to Microsoft Excel. |
StiExportFormat.ODT |
Saves to OpenDocument Text. |
StiExportFormat.ODS |
Saves to OpenDocument Spreadsheet. |
StiExportFormat.CSV |
Saves to CSV (Comma-Separated Values). |
StiExportFormat.IMAGE_SVG |
Saves to SVG. |
After the report is exported, the resulting data stream will be transferred to the web browser for downloading as a file. The file name and MIME data type will be detected automatically.