You must Sign In to post a response.
  • Category: .NET

    Datagrid contend display in excel format whil i click button in windows application

    hi users

    i have one doubt how can i show my gridview content in csv format while i cick my
    button event it will be download excl format in windows application have u any idea means tell me ASP

    then i have sort time period to do this task please send any samples and links ASP

    note : i dont want web application i want windows application
    Thanks in Advance

    vengatesan.p
  • #587213
    hey try this code



    Response.Clear();
    Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/vnd.xls";

    System.IO.StringWriter swtext = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter hwtext = new HtmlTextWriter(swtext);

    DGridexcel.RenderControl(hwtext);
    Response.Write(swtext.ToString());
    Response.End();




    hope this will help you

  • #587221
    Hi,
    Please check out in DNS for this answer. Recently I have uploaded project on this Question.

    Refer this Site
    http://www.dotnetspider.com/projects/1195-Generate-CSV-through-SQL-Server-D.aspx

    Regards,
    Angad Yadav
    ----------------------
    Work Hard,Be Smart

  • #587225
    Hi

    Instead of exporting it in to excel you specify the for you need to export

    csv is a comma delimiter.Comma will be separate each and every fields using csv we can open in any format .



    Response.Clear();
    Response.AddHeader("content-disposition", "attachment;filename=FileName.csv");
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/vnd.csv";

    System.IO.StringWriter swtext = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter hwtext = new HtmlTextWriter(swtext);

    gridview1.RenderControl(hwtext);
    Response.Write(swtext.ToString());
    Response.End();


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.