如果是单个gridview使用一下代码可以导出到excel
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=kq.xls");
Response.ContentType = "application/excel";
EnableViewState = false;
StringWriter swOut = new StringWriter();
HtmlTextWriter hTw = new HtmlTextWriter(swOut);
gvwData.RenderControl(hTw);
Response.Write(swOut.ToString());
ApplicationInstance.CompleteRequest();
Response.Flush();
Response.End();
如果嵌套了gridview则不能导出到excel,请各大能指教!
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=kq.xls");
Response.ContentType = "application/excel";
EnableViewState = false;
StringWriter swOut = new StringWriter();
HtmlTextWriter hTw = new HtmlTextWriter(swOut);
gvwData.RenderControl(hTw);
Response.Write(swOut.ToString());
ApplicationInstance.CompleteRequest();
Response.Flush();
Response.End();
如果嵌套了gridview则不能导出到excel,请各大能指教!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货