Ever wanted to export a Telerik report from a Silverlight application?
This is easily accomplished by instantiating the ReportServiceClient class, which plays the role of proxy to the Telerik Report Service.
To specify that you want to render the report we use the RenderAsync method of the ReportServiceClient, which invokes the respective method on the server (remember that it serves as proxy) that would return the rendered report.
Since we’ve used an asynchronous method and we do not know when the render would finish, we need to handle the RenderCompleted event. In the RenderCompleted event we get the result from the rendering and decide what to do with it - in this case write down the report.\
An interesting part to note here is that we invoke the ShowDialog method prior to having the rendered report, because the dialog box, can only be called from user-initiated code, such as a button Click event. If ShowDialog is called from code that is not user-initiated, a SecurityException is thrown. More info on SaveFileDialog is available in this MSDN article.
Here is the code we've used:
MainPage : UserControl
sender, RoutedEventArgs e)
var fileDlg =
"PDF files|*.pdf|All files|*.*"
.file = fileDlg.OpenFile();
var serviceClient =
"Telerik.Reporting.Examples.CSharp.Report1, CSharp.ReportLibrary, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null"
sender, RenderEventArgs e)
var result = e.RenderingResult;
.file.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
and you'll also find attached a demo application.
P.S. Information about programmatic export and save of Telerik reports for web and windows forms applications is available in our documentation and KB sections:
Check the demo & enjoy!
Stefan’s main interests outside the .NET domain include rock music, playing the guitar and swimming.
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.