Asp.Net Excel’e veri aktarmak

584 gün önce tarafından yazılmıştır.

Aşağıdaki kodları bir butona yerleştirdiğimizde, oradaki “Gridviewiniz” kısmını kendi ayarlayarak, verilerinizi olduğu gibi ‘e aktarabilirsiniz. Rapor.xls olarak masaüstüne kaydedecektir.

HtmlForm form1 = new HtmlForm();

        form1.Controls.Add(Gridviewiniz);

        Response.Clear();

        Response.ClearHeaders();

        Response.ClearContent();

        Response.ContentEncoding = System.Text.Encoding.GetEncoding(“windows-1254″);

        Response.Charset = “windows-1254″; //ISO-8859-13 ISO-8859-9  windows-1254

        System.Web.HttpContext.Current.Response.AddHeader(“content-disposition”, “attachment;filename=Rapor.xls”);

        Response.ContentType = “application/vnd.ms-excel”;

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

        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

        Gridviewiniz.RenderControl(htmlWrite); Devamını Oku

Tüm hakları saklıdır. 2008-2012