gridview导出数据到excel超出数据不显示

qq_27083861 2018-06-06 10:18:03
{
if (GridView1.Rows.Count == 0)
{
Response.Write("<script>alert('没有查找到数据,无法导出!')</script>");
}
else
{
string strStyle = @"<style> .text { mso-number-format:\@; }</style>";
Export(GridView1, strStyle, "application/ms-excel", "myExcel.xlsx");
}
}
private void Export(GridView gvUser, string Style, string FileType, string FileName)
{
Response.ClearContent();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
Response.ContentType = FileType;
//page.Response.ContentType = "application/ms-excel";
Page.EnableViewState = false;
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
//turn off paging
gvUser.AllowPaging = false;
BindGrid(gvUser);

gvUser.RenderControl(hw);
Response.Write(Style);
Response.Write(sw.ToString());
//page.Response.Flush();
Response.End();

//turn the paging on again
gvUser.AllowPaging = true;
BindGrid(gvUser);
}
private void BindGrid(GridView gvUser)
{
gvUser.DataSource = dtResult;
gvUser.DataBind();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
这是我的导出代码,最多只能导出65536行数据,现在新版的EXCEL不是可以导出1048576行的吗,请问怎么修改可以让我把超出65536行的数据也导出来
...全文
431 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eiceblue 2018-06-06
  • 打赏
  • 举报
回复
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧