0
votes

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?

5
i thought reportviewer already have this feature(export to excel) ?Marco Bong
The situation is that I am already having the RDLC format data as pdf in form of bytes present in the aspx page. But I need to introduce both the functionalities. The pdf should be rendered along with a button that will download the excel file to the local system.Prateek Gangopadhyay
Use 2 buttons, one button gives the PDF bytes back, the other button gives the Excel bytes back, and mime types/file names control how the browser deals with the data.ebyrob

5 Answers

1
votes

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/
0
votes

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);
0
votes

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

0
votes

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.