This is a migrated thread and some comments may be shown as answers.

writing a telerik reportbook to asp page in excel format

1 Answer 44 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Edney
Top achievements
Rank 1
Edney asked on 29 Apr 2014, 07:04 PM
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!

1 Answer, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 01 May 2014, 07:47 AM
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.

 
Tags
General Discussions
Asked by
Edney
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or