1 year ago
#62503
Arpechal
EPPlus: cannot calculate simple formula : #VALUE! error
I really don't understand why my (quite simple!) formula won't get calculated:
var logfile = new System.IO.FileInfo(@"C:\EpplusLogFile.txt");
sheet.Workbook.FormulaParserManager.AttachLogger(logfile);
var mycell = sheet.Cells[1, 1];
mycell.Formula = "1+1";
mycell.Calculate();
Console.WriteLine($"{mycell.Address} {mycell.Formula} {mycell.Value}");
sheet.Workbook.FormulaParserManager.DetachLogger();
Console.ReadLine();
- Console displays:
A1 1+1 #VALUE!
- Log file is not created (but no exception is raised)
I'm using EPPlus 5.8.5
Additionally:
var cell1 = sheet.Cells[1, 1];
cell1.Value = 999;
var cell2 = sheet.Cells[1, 2];
cell2.Formula = "A1";
cell2.Calculate();
Console.WriteLine($"{cell2.Address} {cell2.Formula} {cell2.Value}");
Console displays: B1 A1 999
as it's supposed to.
But:
var cell1 = sheet.Cells[1, 1];
cell1.Value = 999;
var cell2 = sheet.Cells[1, 2];
cell2.Formula = "A1+1";
cell2.Calculate();
Console.WriteLine($"{cell2.Address} {cell2.Formula} {cell2.Value}");
And console displays: B1 A1+1 #VALUE!
To me, this makes no sense.
c#
excel
excel-formula
formula
epplus
0 Answers
Your Answer