• 16-05-2014, 14:34:52
    #1
    Merhaba arkadaşlar asp .net e başlıyalı iki gün filan oldu. Biraz c# bilgim var fakat webform oluşturdum. Bu webform da tablo var yalnız bu tablo alışıla gelmiş normal tablo değil. Ben bunu excel olarak kaydedip yada yazıcıdan çıktı almak istiyorum fakat nasıl yapabilirim yardımcı olacak arkadaş var mı ?
  • 16-05-2014, 14:37:07
    #2
    Üyeliği durduruldu
    alışıla gelmiş normal tablo 'dan farkı nedir..
    excel bir alışılagelmiş normal tablodur. alışılagelmiş normal tablo olmayan tablonuz hakkında bilgi verirseniz ona göre cevap düşünsek
  • 16-05-2014, 14:42:31
    #3
    yanlış anlaşıldım galiba alışagelmiş derken tabiki excel dosyası farklı yanı veri tabanı tabloları gibi değil kimi yer küçük kimi yer büyük o açıdan söyledim. Bu şekilde çıktı almak istiyorum excelden

    https://i.hizliresim.com/nPOb6V.jpg
  • 23-05-2014, 09:17:02
    #4
    verileri gridwiev e aktar daha sonra aşağıdaki kodu bir butonun eventine yaz excelle aktarmış olursun


    HtmlForm form = new HtmlForm();

    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
    HttpContext.Current.Response.Charset = "windows-1254";

    string dosya = "attachment;filename=ExcellListesi.xls";

    Response.ClearContent();

    Response.AddHeader("content-disposition", dosya);

    Response.ContentType = "appliction/ms-excel";

    StringWriter sw = new StringWriter();

    HtmlTextWriter hw = new HtmlTextWriter(sw);

    form.Controls.Add(grdListe);

    this.Controls.Add(form);

    form.RenderControl(hw);

    Response.Write(sw.ToString());

    Response.End();
  • 03-06-2014, 11:20:57
    #5
    string sqlMetni = "SELECT * FROM blabla";
    SqlDataAdapter da = new SqlDataAdapter(sqlMetni, Connection.Conn);

    DataTable dt = new DataTable();
    da.Fill(dt);
    DataView raporDataView = new DataView(dt);

    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.Charset = "UTF-8";
    HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
    HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=uye_listesi.xls");

    StringBuilder icerik = new StringBuilder();

    icerik.Append("<table border='1'>" +
    "<tr style='text-align:center; font-weight: bold; background-color: black; color: white;'>" +

    "<td>Email</td>" +
    "<td>CreationDateTime</td>" +

    "</tr>");

    foreach (DataRowView satir in raporDataView)
    {
    icerik.Append("<tr>");

    icerik.Append("<td>" + satir["Email"].ToString() + "</td>");
    icerik.Append("<td>" + satir["CreationDateTime"].ToString() + "</td>");

    icerik.Append("</tr>");
    }

    icerik.Append("</table>");

    HttpContext.Current.Response.Write(icerik);
    HttpContext.Current.Response.End();
    HttpContext.Current.Response.Flush();