Exporting gridpanel content to excel

  1. #1

    Exporting gridpanel content to excel


    I've been struggling for hours trying to find a solution to this problem that i've come across :S, i have to export the content of a gridpanel to a excel file,
    this is supposed to be the function that does it :

    void exportarExcel()
            string attachment = "attachment; filename=Export.xls";
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/ms-excel";
            System.IO.StringWriter sw = new System.IO.StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
    Then i got to my web form and run the app, when i click the button that exports to excel all i get is this error


    in case the image cannot be seen the error is this:

    Status Code: 200
    Status Text: BAD RESPONSE: Unexpected Token <
    Please help! :(
    Last edited by geoffrey.mcgill; Dec 13, 2011 at 8:48 PM. Reason: please use [CODE] tags
  2. #2
    I assume you want the enduser to download an excel spreadsheet?

    Have a look a this sample

    Better yet is to call an httphandler

    rgds /Peter
  3. #3
    It worked out perfectly :D thx

Similar Threads

  1. Exporting Grid Data for Excel, CSV, XML, HTML, PDF [EXAMPLE Codes]
    By fatihunal in forum Examples and Extras
    Replies: 6
    Last Post: Oct 07, 2016, 1:50 PM
  2. [CLOSED] hide a field while exporting data to Excel
    By Fahd in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 20, 2012, 4:46 PM
  3. exporting to excel with gridfilters on
    By norphos in forum 1.x Help
    Replies: 0
    Last Post: Oct 18, 2011, 1:14 PM
  4. Replies: 0
    Last Post: Sep 05, 2011, 10:01 AM
  5. [CLOSED] Excel exporting issue
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Oct 20, 2010, 5:12 PM

Tags for this Thread

Posting Permissions