dot*_*ner 4 c# excel asp.net-mvc-4 epplus
在我的下面的代码中,c4的值为零.C4细胞具有式SUM(C2:C3).EPPlus能够用公式读取细胞吗?为什么c4被设置为零而不是12.
using (var package = new ExcelPackage(existingFile))
{
ExcelWorkbook workBook = package.Workbook;
var currentWorksheet = workBook.Worksheets.First();
currentWorksheet.Cells["C2"].Value = 5;
currentWorksheet.Cells["C3"].Value = 7;
var c4 = Convert.ToDouble(currentWorksheet.Cells["C4"].Value); //c4 is zero. why?
}
Run Code Online (Sandbox Code Playgroud)
从EpPlus 4.0.1.1开始,有一种扩展方法public static void Calculate(this ExcelRangeBase range).在访问C4的Value属性之前调用它:
currentWorksheet.Cells["C4"].Calculate();
Run Code Online (Sandbox Code Playgroud)
并在此之后currentWorksheet.Cells["C4"].Value返回12.
| 归档时间: |
|
| 查看次数: |
5202 次 |
| 最近记录: |