Excel.Application xlApp = new Excel.ApplicationClass();
xlApp.Application.Workbooks.Add(strFilePath);
Excel.Workbook xlBook = xlApp.Workbooks[1];
Excel.Worksheet xlSheet = (Excel.Worksheet)xlBook.Worksheets[1];xlSheet.Name = "aaaaaaaaaaaaaa";
xlApp.Application.Workbooks.Add(strFilePath);
Excel.Workbook xlBook = xlApp.Workbooks[1];
Excel.Worksheet xlSheet = (Excel.Worksheet)xlBook.Worksheets[1];xlSheet.Name = "aaaaaaaaaaaaaa";
你有没有引用EXCEL呀!
....
Excel.Application xlApp = new Excel.Application();//***************!!!!!!
xlApp.Application.Workbooks.Add(strFilePath);
Excel.Workbook xlBook = xlApp.Workbooks[1];
Excel.Worksheet xlSheet = (Excel.Worksheet)xlBook.Worksheets[1];xlSheet.Name = "aaaaaaaaaaaaaa"; GoodLuck
我接分!
DataGrid1.DataSource = oView
DataGrid1.DataBind()
objConn.Close()
objConn.Dispose()
objConn = Nothing
If Request.QueryString("bExcel") = "1" Then
Response.ContentType = "application/vnd.ms-excel"
' 从Content-Type header中去除charset设置
Response.Charset = "" ' 关闭 ViewState
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' 获取control的HTML
DataGrid1.RenderControl(hw)
' 把HTML写回浏览器
Response.Write(tw.ToString())
Response.End()
End If