解决方案 »

  1.   

    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="strFileName"></param>
    /// <returns></returns>
    private void DropExcel(string strFileName)
    {
    string strConnection = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = "
    + strFileName + ";Extended Properties = Excel 8.0";
    OleDbConnection oleConnection = new OleDbConnection(strConnection);
    try
    {
    string strCommondText = " drop table [Sheet1$] ";
    oleConnection.Open();
    OleDbCommand oleAdper = new OleDbCommand(strCommondText,oleConnection);
    oleAdper.ExecuteNonQuery();
    }
    catch(Exception ex)
    {
    throw new Exception("读取数据源文件时出错,错误消息:" + ex.Message);
    }
    finally
    {
    oleConnection.Close();
    }
    }这样可以么
      

  2.   

     Microsoft.Office.Interop.Excel.Application app = 
                    new Microsoft.Office.Interop.Excel.ApplicationClass(); 
    我就是不需要Office的组件,或者有没有其它的方式将数据保存在第一个work sheet1
      

  3.   

    /// <summary> 
    /// 删除 
    /// </summary> 
    /// <param name="strFileName"> </param> 
    /// <returns> </returns> 
    private void DropExcel(string strFileName) 

    string strConnection = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = " 
    + strFileName + ";Extended Properties = Excel 8.0"; 
    OleDbConnection oleConnection = new OleDbConnection(strConnection); 
    try 

    string strCommondText = " drop table [Sheet1$] "; 
    oleConnection.Open(); 
    OleDbCommand oleAdper = new OleDbCommand(strCommondText,oleConnection); 
    oleAdper.ExecuteNonQuery(); 

    catch(Exception ex) 

    throw new Exception("读取数据源文件时出错,错误消息:" + ex.Message); 

    finally 

    oleConnection.Close(); 

    } 这样可以么----------------------------------------------
    这种方式我也尝试过,只能删除数据,不能删除work sheet!
      

  4.   

    或者有没有其它的方式,直接修改sheet的结构,然后填充数据.