View Single Post
  #1 (permalink)  
Old December 14th, 2004, 01:32 PM
see07 see07 is offline
Authorized User
Join Date: Dec 2004
Location: Mexico City, , Mexico.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Export data from a datalist to an Excel sheet

I’m using this code to export data from a datagrid to an Excel sheet:


Response.Buffer= true;

Response.ContentType = "application/";

Response.AddHeader("Content-Disposition", "inline;filename=Clientes.xls");

Response.Charset = "";

this.EnableViewState = false;

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);




And this is working fine.

But now I want to do same with a datalist and thus I changed RenderControl line thus:


Yet when Excel sheet is showing on screen, all data are displayed in one simple column “A”, with one row for each data in datalist.

Does somebody know how can I attain it work as I did as datagrd (each column in datalist into its respective column in Excel)?

I’ll appreciate your suggestions.



El Hombre que tiene Amigos ha de mostrarse Amigo
El Hombre que tiene Amigos ha de mostrarse Amigo