none
Exporting to Excel with Reporting Services without a tab for each page. RRS feed

  • Question

  •  Hi All,

    I currently have a web report written in reporting services displaying in the ReportViewer object.  I have a button on the page to export this report to Excel and it works great however the excel document is rendered with each page of the report displayed on a separate tab (See snippet for export code).  This presents a problem as some of the reports being rendered are well over 100 pages, making it a bear to navigate.  Is there any way to have all of the pages of the report export on to one tab?

    Thanks in advance for any help!!
    -Matt

     

    ExportReport r = new ExportReport();  
    byte[] byteArray = new byte[100];  
    byte[] byteArrayCompressed = new byte[100];  
    string mimeType, encoding, fileNameExtension;  
    string[] streams;  
    string contentType = "";  
    string outputPath = "";  
    string deviceInfo = "";  
    Microsoft.Reporting.WebForms.Warning[] warnings;  
       
    string reportName = ReportViewer1.LocalReport.ReportPath.Substring(ReportViewer1.LocalReport.ReportPath.LastIndexOf("\\"), ReportViewer1.LocalReport.ReportPath.Length - ReportViewer1.LocalReport.ReportPath.LastIndexOf("\\")).Replace("\\", "").Replace(".rdlc", "");  
       
    deviceInfo = "<DeviceInfo>" +  
    "  <OutputFormat>PDF</OutputFormat>" +  
    "  <PageWidth>9.5in</PageWidth>" +  
    "  <PageHeight>11in</PageHeight>" +  
    "  <MarginTop>.25in</MarginTop>" +  
    "  <MarginLeft>.25in</MarginLeft>" +  
    "  <MarginRight>.25in</MarginRight>" +  
    "  <MarginBottom>.25in</MarginBottom>" +  
    "</DeviceInfo>";  
       
    outputPath = "C:\\ReportOutput";  
       
    byteArray = ReportViewer1.LocalReport.Render(ddlExportType.SelectedValue, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);  
    byteArrayCompressed = r.GetCompressedByteArray(fileNameExtension, outputPath + Guid.NewGuid().ToString() + "." + fileNameExtension, byteArray, out contentType);  
       
    //Open the file in memory  
    MemoryStream ms = new MemoryStream();  
    ms.Write(byteArrayCompressed, 0, byteArrayCompressed.Length);  
    Response.AppendHeader("content-disposition", "attachment");  
    Response.Clear();  
    Response.Buffer = true;  
    Response.ContentType = contentType;  
    Response.BinaryWrite(ms.ToArray());  
    Response.End();  
     
    Sunday, November 23, 2008 8:19 AM