当我把GrideView中的数据导出到Excel 时,如果时汉字和数字,字母都能正常,但是但GrideView中含有日期类型时,却什么都倒不出,GridView数据格式为: 02 21 2009 2:37PM 1 大河报,生成代码如下: Response.Clear(); Response.Buffer = false; Response.Charset = "UTF-8"; Response.AppendHeader("Content-Disposition", "attachment;filename=pkmv_de.xls"); Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); Response.ContentType = "application/ms-excel"; Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">");//防止输出乱码 this.EnableViewState = false; System.IO.StringWriter oStringWriter = new System.IO.StringWriter(); HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter); GridView1.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End();
- 2 回答
- 0 关注
- 428 浏览
添加回答
举报
0/150
提交
取消