How to show export button in rdlc, for exporting it to Excel
How to show export button in rdlc, so that i can easily export rdlc files to Excel. Please help me to find a solution.
How to show export button in rdlc, so that i can easily export rdlc files to Excel. Please help me to find a solution.
Hello Dustin Albas,
You can create a custom export to Excel option in RDLC. Please try the code given below that I have attached to this message it is in a Windows Notepad file, it is put together through Microsoft's documentation on Report Viewer and various google searches.
I hope this solves your issue.
Â
Â
Dear Dustin Albas,
You can export rdlc files directly to excel. There is a code behind file to do that and you even don’t need use export button. You have to use the ReportViewer .LocalReport.Render() method and specify that it is an Excel file what you want.
Here is the code:
private void CreateEXCEL(string fileName)
{
  // 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("EXCEL", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
  // Now that you have all the bytes representing the EXCEL 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(); // send it to the client to download
}
Â
Thank You.