本文介绍了绑定后EPPlus不caluculating公式输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用EPPlus。我是停留在单元格公式



我的代码如下:

  ExcelPackage PCK =新ExcelPackage(@D:\MYSheets\EmptyFile.xlsx); 
变种WS = pck.Workbook.Worksheets [MySheet的工作];

ws.Cells [A3]值=2.3。
ws.Cells [A4]值=10.2。

ws.Cells [A5] =公式= SUM(A3:A4)。
ws.Cells [A5] Style.Numberformat.Format =#,## 0.00。
pck.Save();

当我打开Excel,默认情况下,A5小区不计算A3和A4的总和。除非我修改A3和/或A4细胞中,细胞A5一直不计算



我试着用下面的代码,但它并没有为我工作:

  ws.Workbook.CalcMode = ExcelCalcMode.Automatic; 


解决方案

尝试:


$ ; b $ b

  ws.Cells [A3]值= 2.3; 
ws.Cells [A4]值= 10.2。



你告诉EPPlus的值存储为一个字符串,这就是为什么公式失败。


I am using EPPlus. I am stuck at cell formulas.

My code is below:

ExcelPackage pck = new ExcelPackage(@"D:\MYSheets\EmptyFile.xlsx");
var ws = pck.Workbook.Worksheets["MySheet"];

ws.Cells["A3"].Value = "2.3";
ws.Cells["A4"].Value = "10.2";

ws.Cells["A5"].Formula = "=SUM(A3:A4)";
ws.Cells["A5"].Style.Numberformat.Format = "#,##0.00";
pck.Save();

When I open Excel, by default, A5 cell is not calculating the sum of A3 and A4. Unless I modify the A3 and/or A4 cells, the A5 cell remains not calculated.

I tried using the following code but it didn't work for me:

ws.Workbook.CalcMode = ExcelCalcMode.Automatic;
解决方案

Try:

ws.Cells["A3"].Value = 2.3;
ws.Cells["A4"].Value = 10.2;

You were telling EPPlus to store the values as a string, that's why the formula failed.

这篇关于绑定后EPPlus不caluculating公式输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 20:00