+ Reply to Thread
Results 1 to 2 of 2

How to Export to an Excel 2007

  1. #1
    Registered User
    Join Date
    04-13-2007
    Posts
    1

    How to Export to an Excel 2007

    Hi All,

    I have an web 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
    Response.ContentType = "application/vnd.ms-excel";
    Response.AppendHeader("content-disposition", "attachment;
    filename=StackRanking.xls");
    Response.Charset = "";
    System.IO.StringWriter sw = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter hw = new
    System.Web.UI.HtmlTextWriter(sw);
    (........fils dataset..... )
    hw.RenderBeginTag
    System.Web.UI.HtmlTextWriterTag.Html;
    dg.RenderControl(hw);
    hw.RenderEndTag();
    Response.Write(sw);
    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 (downloaded) Excel File,I guess i need framework 3.0 to Support the file format of Excel 2007.
    We all know that it gives error message when we try to open an Excel 2003 file on excel 2007.

    What in the code needs to be changed to have compatibility with Excel 2007 File.....

    Should i completely change the code with some other alternative. If so, what is that alternative

    I posted this query on many forums including Excel.Programming but with no success so far. Hope i get help here...

    Thanks for reading my query...

  2. #2
    Registered User
    Join Date
    03-08-2007
    Location
    Brisbane, Australia
    Posts
    57

    word from the ignorant . ..

    Don't really know the difference, but all the websites i've gone to present data in a CSV file which will usually open in Excel (unless the user has changed their own PC settings)

    Probably no use to you, as it ignores formatting etc, but just a thought. . .


    james

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1