The OnAfterReportExportSuccess event (v2018.2.14+, v2019.1.1+) will be called after a report execution export file has been generated for a specified report. The server event implementation may load the export file from disk using the supplied file path, exportFilePath, modify the file, then save the changes back to disk. If the server event implementation saves changes to the export file, the file must be saved with the same filename that is passed in as the exportFilePath.
Caution: If the file is saved to a different path, modifications will not be honored by Exago.
This server event will be called for all report execution export files generated, including those generated via:
- Execution in the web app process (remote execution disabled)
- Remote execution
- Scheduled execution (including those using the Scheduler Queue)
- Batch scheduled executions
It is compatible with HTML, PDF, RTF, Excel, and CSV export types.
For custom code the args array is structured as follows:
args contains two arguments: args should contain a string representing the file path of the exported report, and args should contain a wrExportType object representing the export type of the report.
For .Net Assemblies the method signature is as follows:
void EventHandlerName(SessionInfo sessionInfo, string exportFilePath, wrExportType exportType)
The return value of this event is ignored.
Use Case and Custom Code Example
A primary use case of the OnAfterReportExportSuccess server event is to intercept an output file before it is emailed and make modifications to the file. After the event resolves, email processes should proceed as normal.
In the following example, text is added to a CSV export:
Global Event: OnAfterReportExportSuccess
if(args.ToString().ToLower() == "csv")
using (FileStream fs = File.Open(args.ToString(), FileMode.Open, FileAccess.Write, FileShare.None))
Byte info = new UTF8Encoding(true).GetBytes("This is some text.");
// Add some information to the file.
fs.Write(info, 0, info.Length);