Error Export DataTable to Excel

  1. #1

    Error Export DataTable to Excel

    i need Help...

    i try to export a simple datatable and reporting error Status Code: 200Status Text: BADRESPONSE: missing } in XML expression.

    in diferents times the valor missing } change for ; > . )...

    Click image for larger version. 

Name:	exporterror.png 
Views:	134 
Size:	21.1 KB 
ID:	3679

    the code using is:

    objDataSetGrid4 = objInventario.ListarPronosticos();
            DataTable dt = objDataSetGrid4.Tables[0];
            //Create a dummy GridView
            System.Web.UI.WebControls.GridView GridView1 = new System.Web.UI.WebControls.GridView();
            GridView1.AllowPaging = false;
            GridView1.DataSource = dt;
            GridView1.DataBind();
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
             "attachment;filename=DataTable.xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                //Apply text style to each Row
                GridView1.Rows[i].Attributes.Add("class", "textmode");
            }
            GridView1.RenderControl(hw);
            //style to format numbers to string
            string style = @"<style> .textmode { mso-number-format:\@; } </style>";
            Response.Write(style);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
    Last edited by geoffrey.mcgill; Jan 10, 2012 at 5:44 PM. Reason: please use [CODE] tags
  2. #2
    You can try searching in the forum for similar threads. For example, I found this:

    http://forums.ext.net/showthread.php...ORT-EXCEL-FILE
    Last edited by geoffrey.mcgill; Jan 10, 2012 at 5:44 PM.
  3. #3
    Thanks for te answer but???? where configure IsUpload="true" for AjaxEvent to return file

    I try config but dont find where put this instruction...
  4. #4
    It should be a property on DirectEvent now.
  5. #5

    Thanks

    Thanks Very Much.. its works perfect

Similar Threads

  1. Export to Excel
    By JonC in forum 1.x Help
    Replies: 9
    Last Post: Nov 13, 2012, 4:59 AM
  2. Excel Export
    By maephisto in forum 1.x Help
    Replies: 1
    Last Post: May 13, 2011, 11:47 AM
  3. vb example of export to Excel
    By grosenbrock in forum 1.x Help
    Replies: 2
    Last Post: Aug 27, 2010, 6:22 PM
  4. Replies: 3
    Last Post: Mar 16, 2010, 1:50 PM
  5. Replies: 2
    Last Post: May 15, 2009, 9:41 AM

Posting Permissions