问题描述
gridview中数据显示正常导出excel后出现以下问题:账号异常,数据位置不对齐导出excel代码如下:GridView1.AllowPaging=false;//取消分页,使GridView显示全部数据.Response.Clear();Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls");//设置输出流为简体中文Response.Charset="GB2312";Response.ContentEncoding=System.Text.Encoding.GetEncoding("UTF-8");//设置输出文件类型为excel文件。Response.ContentType="application/vnd.ms-excel";StringWritersw=newStringWriter();HtmlTextWriterhtw=newHtmlTextWriter(sw);GridView1.RenderControl(htw);Response.Output.Write(sw.ToString());Response.Flush();Response.End();GridView1.AllowPaging=true;
时间: 2024-10-06 02:47:48