C# 通过OLEDB更新EXCEL后,原来的公式就失效了

在VS2012中,通过OLEDB更新EXCEL(2016版本)后,excel里原来的公式就失效了。
比如 A1 A2 A3
1 2 3
这里A3为公式,A3=A1+A2
但是,我通过OLEDB将A1改成10之后,A3仍然是3,没有更新成13.
-------------c#代码如下--------------------
string strCon = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + Path + ";Extended Properties='Excel 12.0; HDR=No; IMEX=0'";
OleDbConnection myConn = new OleDbConnection(strCon) ;
myConn.Open();
string sql = string.Format("update [Sheet1$] set A1= 10 where A0=1");
OleDbCommand myCommand1 = new OleDbCommand(sql, myConn);
myCommand1.ExecuteNonQuery();
Select();
myConn.Close();
--------------------------------------------
求高手帮忙啊,愁死了

用这个NPOI
关键代码//要求公式重算结果
sheet.ForceFormulaRecalculation = true;
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-07-05
这个可能得调用一下excel interop追问

不太明白啊~~,能不能给个例子说明下啊?

追答

百度 excel interop

第2个回答  2017-07-05
你的读取语句放出来,看看,应该是你的数据类型没有搞对追问

我在上面写了,你展开来就能看到了。

相似回答