我有一个包含超过 3000 条记录的 Excel 工作表,我想更新具有类似表达式的特定列的值=N8*(1+Q8)
。
System.Data.OleDb.OleDbConnection connection;
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();
string query = null;
connection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sourcefile + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";");
connection.Open();
cmd.Connection = connection;
query = "Update [Data$] Set [" + Column1 + "] = '" + value1 + "' where ShortCust Like '%" + customername + "%' AND ShortProd Like '%" + productname + "%'";
cmd.CommandText = query;
cmd.ExecuteNonQuery();
connection.Close();
当我运行此应用程序以更新获取错误
“无法更新'(表达式)';字段不可更新。”
如何更新此 Excel 列?