Export to excel problem

2 posts, 0 answers
  1. Dayana Maliyakal
    Dayana Maliyakal avatar
    27 posts
    Member since:
    Jan 2010

    Posted 06 Jan 2012 Link to this post

    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

  2. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 06 Jan 2012 Link to this post

    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,
Back to Top