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

Export to excel problem

1 Answer 97 Views
AJAX and Web 2.0
This is a migrated thread and some comments may be shown as answers.
Dayana Maliyakal
Top achievements
Rank 1
Dayana Maliyakal asked on 06 Jan 2012, 01:39 PM
Hi Telerik Team,

   I am trying to export some data to excel and my code is as below:

 

 

protected byte[] rptResult = null;

 

rptResult = //getdata here

 

Response.ClearContent();

Response.AppendHeader(

 

"content-length", this.rptResult.Length.ToString());

 

Response.AppendHeader(

 

"content-disposition", "attachment;filename=Test.xls");

 

Response.ContentType =

 

"application/vnd.ms-excel";

 

Response.Buffer =

 

true;

 

Response.BinaryWrite(

 

this.rptResult);

 

Response.Flush();

 

 

Response.Close();

But after executing I got an error like below:

Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

I think the error is coming from the code like

 

Response.BinaryWrite(this.rptResult);

 

 

 

 
Waiting for the reply
Dayana

1 Answer, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 06 Jan 2012, 05:47 PM
Dayana:

Which Telerik product are you using to format and display your data? Most of the data products, such as the RadGrid offer convenient "ExportToExcel" functionality that handles all of the request/response functionality intrinsically.

Please provide more details.

Regards,
Tags
AJAX and Web 2.0
Asked by
Dayana Maliyakal
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or