摘要:gridview的html滙出成excel
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="p310100.aspx.cs" Inherits=.pCMM310100" EnableEventValidation="false" %>
string strFileDirectory = "~/UserData/Publish/Attach/";
string strFileName = Session["USR_ID"].ToString() + "-" + DateTime.Now.ToString("yyyyMMddmmss") + ".xls";
string strAttachFile = strFileDirectory + strFileName;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
gv_DESC.RenderControl(hw);
FileStream fs = new FileStream(Server.MapPath(strAttachFile), FileMode.Create);
StreamWriter BWriter = new StreamWriter(fs, Encoding.GetEncoding("UTF-8"));
BWriter.Write(tw);
BWriter.Close();
fs.Close();