真是奇怪了GridView 导出到excel 数据都为0
在VS里调试导出数据都是成功的,发布到服务器后导出的数据全部是0.这个到底是为什么呀!导出代码:GridView3.AllowPaging=false;//清除分页Gri...
在VS 里调试 导出数据都是成功的,发布到服务器后 导出的数据全部是0. 这个到底是为什么呀!
导出代码:
GridView3.AllowPaging = false; //清除分页
GridView3.AllowSorting = false; //清除排序
GridView3.DataSourceID = "ObjectDataSource3"; // 确定数据源
GridView3.DataBind();
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=rain.xls"); //.xls的文件名可修改
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/ms-excel"; //设置输出文件类型为excel文件。
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
GridView3.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
Response.Flush();
Response.End();
GridView3.AllowSorting = true; //恢复分页
GridView3.AllowPaging = true; //恢复排序
GridView3.DataSourceID = "ObjectDataSource3"; // 确定数据源
GridView3.DataBind();
为什么 发布到服务器都不行了呢。 展开
导出代码:
GridView3.AllowPaging = false; //清除分页
GridView3.AllowSorting = false; //清除排序
GridView3.DataSourceID = "ObjectDataSource3"; // 确定数据源
GridView3.DataBind();
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=rain.xls"); //.xls的文件名可修改
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/ms-excel"; //设置输出文件类型为excel文件。
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
GridView3.RenderControl(oHtmlTextWriter);
Response.Output.Write(oStringWriter.ToString());
Response.Flush();
Response.End();
GridView3.AllowSorting = true; //恢复分页
GridView3.AllowPaging = true; //恢复排序
GridView3.DataSourceID = "ObjectDataSource3"; // 确定数据源
GridView3.DataBind();
为什么 发布到服务器都不行了呢。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询