Exprot to Excel in ASP.NET using C#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 1
Reputation: amitabhwankhede is an unknown quantity at this point 
Solved Threads: 0
amitabhwankhede amitabhwankhede is offline Offline
Newbie Poster

Exprot to Excel in ASP.NET using C#

 
0
  #1
Apr 10th, 2007
Hi All,
I have an application where user can export the results of search action to an excel file so he can locally store it.. I have done this with very simple code which is
  1.  
  2. Response.ContentType = "application/vnd.ms-excel";
  3. Response.AppendHeader("content-disposition", "attachment; filename=StackRanking.xls");
  4. Response.Charset = "";
  5. System.IO.StringWriter sw = new System.IO.StringWriter();
  6. System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
  7. ........fils dataset..... hw.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Html);
  8. dg.RenderControl(hw);
  9. hw.RenderEndTag();
  10. Response.Write(sw);
  11. Response.End();

All work fine when end user has Excel 2003 but when he has Excel 2007 it gives a warning err message when he tries to open the rendered Excel File,
I guess i need framework 3.0 to Support the file format of Excel 2007. What in the code needs to be changed to have compatibility with Excel 2007 File.....:rolleyes:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC