I'm creating new .xlsx file using the template.xltx file. The template file(Template.xltx) contains Table and formulas. The Formula is added in .xltx file, in order to validate if the Table has data or not.
When I tried to retrieve the final result value at Cell[31,1], it is not returning the computed value. Instead it is returning the value that is in the template. Can you please help?
Template file:
EPPLus code:
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();