Prateek
Prateek

Reputation: 145

RDLC export to excel functionality in the UI

Initially I was having the requirement to display a report in the aspx page taking a RDLC as reference in .NET.

This is what I did: I made the entire flow such that, after performing the database operations, the Process layer in my application simply returns the byte[] to the aspx page instead of the LocalReport/ReportViewer object. And in the aspx page, I am rendering the data as Response.BinaryWrite().

But there is a new requirement. There should be an export to excel functionality for the report that is rendered in the UI. As I am returning a byte [] to the UI the page in the IE opens as a pdf page. So I am unable to understand how shall I implement the export-to-excel button.

I further tried to implement it by introducing an user-control and the things got more complicated.

What should I do in this case?

Upvotes: 0

Views: 2785

Answers (5)

Prateek
Prateek

Reputation: 145

The answer is simple. I was a newbie then. Design an aspx page with reportviewer control. Set the report viewer controls path, dataset via code. The report viewer control of Microsoft has export functionality. There is a way to limit the export options as well. You can limit it to export the report in your own customized set of file types you want. But beware of the refresh button functionality. If not required, hide the button. Using the refresh button, May slow down the application performance if the data set retrieves the values from database.

Upvotes: 0

Davis Jebaraj
Davis Jebaraj

Reputation: 403

Syncfusion Essential Report Viewer can be used to output the RDLC to Excel.

Example

Export to Excel

enter image description here

The entire product is available for free with no limitations through the community license if you qualify (less than 1 million USD in revenue).

Note: I work for Syncfusion

Upvotes: 0

Prateek
Prateek

Reputation: 145

It's easy now. Create one page just for the report viewing purpose.

http://www.aspsnippets.com/Articles/How-to-create-RDLC-report-step-by-step-in-ASPNet-using-C-and-VBNet.aspx

Upvotes: 0

kagundajm
kagundajm

Reputation: 1200

Change the format to which the report will be rendered to Excel. Supported extensions are Excel, PDF, Word, and Image.

 byte[] bytes = ReportViewer1.LocalReport.Render( "Excel", null, 
                   out mimeType, out encoding,  out extension, 
                   out streamids, out warnings);

Upvotes: 0

Tom Stickel
Tom Stickel

Reputation: 20411

I had a very similar requirement 3 years ago. The biggest problem I recall facing was that the RDLC export to excel was getting limited by the .net version that I was forced to work on. I recall the application was in Visual Studio 2008, so I'm guessing that I before .net 4.0

  1. Don't use RDLC ( the client free version is not robust like RDL with SSRS) OR
  2. Add the ported over NPOI library and use this to export to Excel , that IS what I did BTW https://npoi.codeplex.com/

Upvotes: 1

Related Questions