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";

解决方案 »

  1.   

    在执行第一句Excel.Application xlApp  = new Excel.ApplicationClass();就出现“拒绝访问”的错误?
      

  2.   

    不会呀
    你有没有引用EXCEL呀!
      

  3.   

    知道了
    ....
    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
                                                  我接分!
      

  4.   

    Dim oView As New DataView(objDataset.Tables(0))
        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