944,113 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 11232
  • C# RSS
Apr 10th, 2007
0

Exprot to Excel in ASP.NET using C#

Expand Post »
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
C# Syntax (Toggle Plain Text)
  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:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amitabhwankhede is offline Offline
1 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: String -> Binary -> TextBox -> AARGH!
Next Thread in C# Forum Timeline: How to search for a string in a file





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC