Quantcast
Channel: Excel Export Sorunu
Viewing all articles
Browse latest Browse all 4

Excel Export Sorunu

$
0
0

Arkadaşlar ürünler tablosunu excel e kaydettikten sonra indirilen excel i açmaya kalktığımda açmaya çalıştığınız ... dosyası dosya uzantısı tarafından belirtilenden farklı bir biçimde. .... şeklinde bir uyarı veriyor. açılışta bu uyarıyı yapmasının sebebi nedir acaba ?

Kodlar ;

protected void btnAktar_Click(object sender, EventArgs e)
    {
        System.IO.TextWriter textWriter = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlTextWriter = new System.Web.UI.HtmlTextWriter(textWriter);
        DataTable dataTable = klas.GetDataTable("select top 118 * from urunler");
        DataGrid dataGrid = new DataGrid();
        dataGrid.DataSource = dataTable;
        dataGrid.DataBind();
        Response.Clear();
        Response.ContentEncoding = System.Text.Encoding.Unicode;
        Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
        Response.Charset = "windows-1254";
        Response.Buffer = true;
        Response.ContentType = "application/vnd.ms-excel"; 
        Response.AddHeader("content-disposition", "attachment;filename=urunler.xls");
        this.EnableViewState = false;
        System.IO.StringWriter sw = new System.IO.StringWriter();
        Encoding.GetEncoding(1254).GetBytes(sw.ToString());
        Response.Charset = "";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
        System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter(sw);
        dataGrid.RenderControl(htw);
        Response.Write("<meta http-equiv='Content-Type' content='text/html; charset=windows-1254' />" + sw.ToString());
        Response.End();
    }


Web Developer



Viewing all articles
Browse latest Browse all 4

Latest Images