我的以下几个要求,可以满足其中以个就可以了。1、
DROP TABLE [Sheet2$]
这句话可以执行过去,但是根本没有任何效果,工作表2依然存在!2、
ALTER TABLE [Sheet2$] add xxxx nvarchar
这句话不让执行!不知为何,提示“无效的操作”

解决方案 »

  1.   

    http://topic.csdn.net/u/20090324/16/f43c3a4f-435b-4004-86eb-f68c8a839945.html
      

  2.   

    楼上这位大哥!!
    我说的是,采用 ado.net那玩意效率低,还得装OFFICE,不好用!!
      

  3.   

    string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + excelSavePath + ";" + "Extended Properties=Excel 8.0;";
                 using (OleDbConnection conn = new OleDbConnection(strConn))
               {
                    conn.Open();
                    string[] sheets = GetSheets(conn);
                    for (int i = 0; i < sheets.Length; i++)
                    {
                         if (sheets[i].Equals(sheetName, StringComparison.OrdinalIgnoreCase))
                         {
                             using (OleDbCommand cmd = conn.CreateCommand())
                             {
                        cmd.CommandText = string.Format("DROP TABLE {0} ", sheetName);
                           cmd.ExecuteNonQuery();
                            }
                           break;
                      }
                    }
           }
    http://forums.asp.net/p/1427875/3193017.aspx#3193017