读书人

出excel,该如何解决

发布时间: 2012-10-20 14:12:48 作者: rapoo

出excel

C# code
LinkButton onebtn = (LinkButton)sender;        GridViewRow gr = onebtn.Parent.Parent as GridViewRow;        int rowindex = gr.RowIndex;        Response.Clear();        Response.Buffer = true;        Response.Charset = "GB2312";        Response.AppendHeader("Content-Disposition", "attachment;filename=List.xls");        Response.ContentEncoding = System.Text.Encoding.UTF8;        Response.ContentType = "application/vnd.ms-excel";        System.IO.StringWriter oStringWriter = new System.IO.StringWriter();        System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);        for (int i = 0; i < this.dgrd_AppInfo.Rows.Count; i++)        {            this.dgrd_AppInfo.Rows[i].Visible = false;        }        this.dgrd_AppInfo.Rows[rowindex].Visible = true;


出一行出中文,多行不出,求大神指。

[解决办法]
Response.Write("<meta http-equiv=Content-Type content=application/ms-excel;charset=UTF-8>");
加在这个后面Response.Clear();

读书人网 >C#

热点推荐