We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Starting in 2019, the Reporting control is no longer included in Essential Studio®. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Export Report as XLS

Hi there,

I'm wondering if there is any way to expert a report loaded in a report viewer as XLS via Code. Especially because the standard report viewer has the capability to export as xls via the menu, but the
"Export" function of the ReportViewer-Object or rather the ExportType-Enumeration has no XLS-Type.

Any advice would be appreciated!

Cheers,
Michael 

4 Replies

MF Michael Faisst April 3, 2016 06:32 PM UTC

My bad, I meant XPS of course!


VS Vinoth Srinivasan Syncfusion Team April 5, 2016 10:45 AM UTC

Hi Michael,

You can export the report to XPS by using the fixed document of the rendered report. ReportViewer has “GetFixedDocument()” that returns the FixedDocument format, it can be given as input to the XPS document generator as shown in below code sample. 

var package = Package.Open(dlg.FileName, FileMode.Create);

                    var xpsDoc = new XpsDocument(package, CompressionOption.Normal);

                    XpsDocumentWriter xpsWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc);


                    // xps documents are built using fixed document sequences

                    var fixedDocSeq = new FixedDocumentSequence();

                    var docRef = new DocumentReference();

                    docRef.BeginInit();

                    docRef.SetDocument(reportViewerControl.GetFixedDocument());

                    docRef.EndInit();

                    ((IAddChild)fixedDocSeq).AddChild(docRef);


                    // write out our fixed document to xps

                    xpsWriter.Write(fixedDocSeq.DocumentPaginator);


                    xpsDoc.Close();

                    package.Close();


Also we have prepared a sample based on this and it can downloaded from the below link.
http://www.syncfusion.com/downloads/support/directtrac/123606/REPORT~1-1124290928.ZIP

Regards,
Vinoth.S


MF Michael Faisst April 5, 2016 01:24 PM UTC

Hi Vinoth,

works like a charm!

Thanks very much!


VS Vinoth Srinivasan Syncfusion Team April 6, 2016 04:20 AM UTC

Hi Michael

Thanks for your update.

Please let us know if you need any further assistance.

Regards,
Vinoth.S

Loader.
Up arrow icon