writing a telerik reportbook to asp page in excel format

2 posts, 1 answers
  1. Edney
    Edney avatar
    2 posts
    Member since:
    Apr 2014

    Posted 29 Apr 2014 Link to this post

    I have a method that sends a report out to the browser in excel format. It works fine if I pass it a report but when I pass it a report book I get the error "Excel found unreadable Content in 'MyReportName.xls'. Do you want to recover the contents of this workbook? If you trust the source of the workbook click Yes. When I click Yes it generates the workbook with all of the tabs in place the only issue is the first tab has the correct name and the remaining tabs are named Recovered_Sheet1, Recovered_Sheet2 ..... Recovered_Sheet10.
    private void WriteToExcel(IReportDocument report)
    {
        ReportProcessor reportProcessor = new ReportProcessor();
        RenderingResult result = reportProcessor.RenderReport("xls", report, null);
     
        Response.Clear();
        Response.ContentType = result.MimeType;
        Response.Cache.SetCacheability(HttpCacheability.Private);
        Response.Expires = -1;
        Response.Buffer = true;
     
        Response.AddHeader("Content-Disposition",
                           string.Format("attachment;FileName=\"{0}.xls\"", result.DocumentName));
     
        Response.BinaryWrite(result.DocumentBytes);
        Response.End();
    }

    Thanks in advance for any and all help!
  2. Answer
    Stef
    Admin
    Stef avatar
    3047 posts

    Posted 01 May 2014 Link to this post

    Hi Edney,

    Please test the solution suggested by my colleague in the following forum thread: Errors when saving report book reports to Excel.

    Regards,
    Stef
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
Back to Top