Click here to Skip to main content
15,077,377 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am working on windows application in which showing an rdlc report, Now i need to hide the report viewer toolbar and place an button and dropdown with options of Excel/PDF/Word, so when ever we select and click export button, the report should be exported, Can anyone guide me...
Posted

1 solution

1- Disable the toolbar.
2- Add a button control to the form. For the Text property of the button, type Export to PDF File.
3- Double-click the button control to specify code for the Click event.

// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;

// Setup the report viewer object and get the array of bytes
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "YourReportHere.rdlc";

byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);

// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush();
   
Comments
sathya4260 12-Sep-11 10:19am
   
i can't able to get "Response" in my code as i am working on windows application
sathya4260 13-Sep-11 6:00am
   
Did there is no developers to clarify my doubt,
Muhammad Shahid Farooq 14-Sep-11 2:13am
   
Above mentioned solution works. It's for windows application in C#. Please explain what you want if you can't understanding the solution?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900