In this article
You may encounter a situation where you want to keep the content viewed on the screen as read-only and not exportable. For example, a simple script on the table in the report can be used to remove the existing banner and replace it with a customized export banner. Basic Setup Requirements for this are as follows:
- The report must include a page with an aggregated table.
- The aggregated table must have a banner header in the column section.
- There must be an additional banner designed for exports.
Figure 1 - The basic requirements
Each banner has a unique ID, which you can see by right-clicking on the banner to see the properties:
Figure 2 - The banner ID
Once the Banner is duplicated and the Banner ID is available, right-click the Table to add the script.
Replacing a Banner in a Table when exporting the report to Excel
if (state.ReportExecutionMode == ReportExecutionMode.ExcelExport) //Checking for the export type
{
var project : Project = report.DataSource.GetProject("ds0"); //Getting the Data Source
var ben : HeaderBanner = new HeaderBanner("ds0", "ban1"); //Creating the new Banner ID
table.ColumnHeaders.Clear(); //Clearing the old Banner from the table header
table.ColumnHeaders.Add(ben); //Assigning the new Banner ID
}
The text in the 3rd line of code “ds0” refers to the Data source ID which is also available via right-clicking to get to data source properties. However if there is only one data source, by default this will be “ds0”.
Now when you export the table in Excel, the Banner Header will be changed for your Table.
Hide scripts based on the export type can also be used for removing content in the exported report.