The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

Exporting gridpanel content to excel

  1. #1

    Exporting gridpanel content to excel

    Hello,

    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.ClearContent();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/ms-excel";
            System.IO.StringWriter sw = new System.IO.StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            gridRegistroInserciones.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();    
        }
    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

    http://imageshack.us/photo/my-images/844/capturavb.png/

    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
    http://examples1.ext.net/Examples/Gr...ort_Data_Ajax/

    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: 5
    Last Post: Sep 04, 2012, 10:41 PM
  2. [CLOSED] hide a field while exporting data to Excel
    By Fahd in forum 1.x 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 Premium Help
    Replies: 9
    Last Post: Oct 20, 2010, 5:12 PM

Tags for this Thread

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.