Overview
Version
Report Server Version | Functional Change |
---|---|
11.0 | / |
Application Scenario
After the report server is started, you can directly export a report as a file in a needed format by entering an access URL (following an export parameter and an export format) on the browser, without opening the template or viewing the report.
For example, you can export the content of two parameters in a checkbox query template as an Excel file, as shown in the following figure.
Implementation Method
You can add ¶meter name=xxx at the end of the URL to export parameters in a template. You do not need to add ¶meter name=xxx if the template has no parameters.
You can add &format=Export format at the end of the URL to export parameters as an Export format file.
The default file name after URL export is the report name. You can also rename the file name.
Export Format Writing Method
Export Format Comparison Table
The following table describes the writing methods for various export formats.
Export Format | Classification | Parameter Value |
---|---|---|
&format=pdf | ||
Excel | Pagination Export (in XLSX format) | &format=excel |
Unaltered Export (in XLSX format) | &format=excel&extype=simple | |
Page to Sheet Export (in XLSX format) | &format=excel&extype=sheet | |
Pagination Export (in XLS format) | &format=excel&extype=page&isExcel2003=true | |
Unaltered Export (in XLS format) | &format=excel&extype=simple&isExcel2003=true | |
Page to Sheet Export (in XLS format) | &format=excel&extype=sheet&isExcel2003=true | |
Word | &format=word | |
Image | JPG Format | &format=image&extype=JPG |
PNG Format | &format=image&extype=PNG | |
GIF Format | &format=image&extype=GIF | |
BMP Format | &format=image&extype=BMP | |
Text File | &format=text Note: Content such as images and slashes cannot be exported. | |
SVG | &format=svg | |
CSV | &format=csv |
Notes
1. The format for the exported Excel file is XLS by default in JAR packages before 2016-10-10.
2. If you want to export data in a specific sheet of a multi-sheet report, the parameter value is &sheets=[Sheet number]. The sheet number starts from 0. If you want to export data in multiple sheets, the sheet number needs to be separated by commas. For example, if you export data in sheet1, the parameter value is &format=excel&sheets=[0]. If you export data in sheet1 and sheet2, the parameter value is &format=excel&sheets=[0,1].
3. To export data in a specific sheet of a multi-sheet report, if the number of the to-be-exported sheet is greater than or equal to 10, you need to use &sheets=[10,] or re-encode the number array through &sheets='+encodeURIComponent("[10]").
4. When you obtain the value of sessionID in the current report through JavaScript and concatenate the value with other parameters into a URL for Excel file export, if you want to export the values of the modified widget on the page and the values passed from the widget on the parameter panel to the cell, you need to use op=export&format=excel, rather than &format=excel.
5. The exported template may not be self-adaptive during URL export.
6. URL export is not supported on mobile terminals.
Export Button Adding After the Parameter Query
If you hope that a template can be exported through the export button after parameters are queried in the report (an extension scenario), you can refer to the following method.
1. Open the built-in report in the path %FR_HOME%\webroot\WEB-INF\reportlets\GettingStartedEN.cpt.
2. Add a button widget on the parameter panel and name the widget Export.
3. Add a click event to export the template as an Excel file after clicking the button.
Set a parameter named aaa and set its value to sessionID (formula type).
JavaScript codes are as follows:
var REPORT_URL = '${servletURL}?op=export&format=excel&sessionID=' + aaa;
window.location = encodeURI(REPORT_URL);
Save and preview the template. You can click Export to export the template as an Excel file after querying parameters.