[英]Is it possible to read the excel cell value with formula?
在我的下面的代碼中,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?
}
從EpPlus 4.0.1.1開始,有一個擴展方法public static void Calculate(this ExcelRangeBase range)
。 在訪問C4的Value屬性之前調用它:
currentWorksheet.Cells["C4"].Calculate();
和currentWorksheet.Cells["C4"].Value
將返回12
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.