无法在EPPLUS中检索实际公式结果

问题描述 投票:0回答:1

我正在使用template.xltx文件创建新的.xlsx文件。模板文件(Template.xltx)包含表和公式。将公式添加到.xltx文件中,以验证表是否具有数据。

[当我尝试在Cell [31,1]上检索最终结果值时,它没有返回计算值。而是返回模板中的值。你能帮忙吗?

模板文件:

“

EPPLus代码:

FileInfo templateFile=new FileInfo("C:\\Template.xltx");
FileInfo excelFile=new FileInfo("C:\\Result.xlsx");
var package=new ExcelPackage(excelFile,templateFile);
package.Workbook.Worksheets[0].Cells[4, 1].Value = "test12";
package.Workbook.Worksheets[0].Cells[4, 2].Value = "1";
package.Workbook.Worksheets[0].Cells[4, 3].Value = "asfdf";
package.Workbook.Worksheets[0].Cells[4, 4].Value = "a333f";
package.Workbook.Worksheets[0].Cells[21, 1].Value = "test12";
package.Workbook.Worksheets[0].Cells[21, 2].Value = "1";
package.Workbook.Worksheets[0].Cells[21, 3].Value = "asfdf";
package.Workbook.Worksheets[0].Cells[21, 4].Value = "a333f";
ExcelCalculationOption option=new ExcelCalculationOption();
option.AllowCirculareReferences = true;
package.Workbook.Worksheets[0].Calculate(option);
package.Save();
Assert.AreEqual("Success", package.Workbook.Worksheets[0].Cells[31,1].Value);
package.Dispose();
epplus epplus-4
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.