将数据导入 Excel 文件中
在 .NET 中如何将表格中的数据导入 Excel文件中??
Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
'导出EXCEL
Public Shared Sub ToExcel(ByVal dgrd As GridView, ByVal strName As String)
Dim rs As System.Web.HttpResponse = HttpContext.Current.Response '定义RESPONSE类
rs.Clear()
rs.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8")
rs.Charset = "UTF-8"
rs.AddHeader("content-disposition", "attachment;filename=" & strName & ".xls")
rs.ContentType = "application/vnd.xls"
Dim stringWriter As = New ()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWriter)
dgrd.RenderControl(htmlWrite)
rs.Write(stringWriter.ToString())
rs.End()
End Sub