Modify excel cell

后端 未结 5 1022
轮回少年
轮回少年 2020-12-31 18:54

Good morning, I would like to edit some cells from already existing excell file. I tried use EPPlus and normal OpenXml classes. However I failed. In both situation program w

5条回答
  •  被撕碎了的回忆
    2020-12-31 19:26

    //this help you to set cells in file excel : using System.Data.OleDb;

            string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Directory.GetCurrentDirectory() + "/swtlist.xlsx;" +
                         @"Extended Properties='Excel 12.0;HDR=Yes;';Persist Security Info=False;";
    
    
            using (OleDbConnection connection = new OleDbConnection(connString))
            {
                connection.Open();
                try
                {
    
                    OleDbCommand cmd = new OleDbCommand("UPDATE  [Feuil1$]  SET d='yes' ", connection);
    
                      cmd.ExecuteNonQuery();
                    connection.Close();
    
    
                }
                catch (Exception ex) { }
            }
    

提交回复
热议问题