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.
Unfortunately, activation email could not send to your email. Please try again.

Export Report as XLS

Thread ID:

Created:

Updated:

Platform:

Replies:

123606 Apr 3,2016 02:02 PM Apr 6,2016 12:20 AM WPF 4
loading
Tags: ReportViewer
Michael Faisst
Asked On April 3, 2016 02:02 PM

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 

Michael Faisst
Replied On April 3, 2016 02:32 PM

My bad, I meant XPS of course!

Vinoth Srinivasan [Syncfusion]
Replied On April 5, 2016 06:45 AM

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

Michael Faisst
Replied On April 5, 2016 09:24 AM

Hi Vinoth,

works like a charm!

Thanks very much!

Vinoth Srinivasan [Syncfusion]
Replied On April 6, 2016 12:20 AM

Hi Michael

Thanks for your update.

Please let us know if you need any further assistance.

Regards,
Vinoth.S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;