Search code examples
c#asp.net.netepplus-4

EPPlus returns #VALUE! instead of Value from the cell content randomly [epplus]


As per Current requirement I need to read value from the cell using EPPlus. This cell contains the formula and showing value correctly in XL Sheet. but when i am reading that value using EPPlus some cells are giving correct value but some cells are giving error "#VALUE!". I have used ".Calculate()" before read the value but still facing the same problem. Please find the code below in c#.

totalRecycleWorksheet.Cells[row, colval + 5].Style.Numberformat.Format = "#";

totalRecycleWorksheet.Cells[row, colval + 5].Calculate();

var value = totalRecycleWorksheet.Cells[row, colval + 5].Value;

if (!totalRecycleWorksheet.Cells[row, colval + 5].Value.ToString().Equals("#VALUE!")) {}

and here is the formula in every cells:

=IF(('Failure Item'!E348+ROUNDUP(('Output'!E348)*$B$1,0)-'Purchased Items'!F348)>0,('Failure Item'!E348+ROUNDUP(('Output'!E348)*$B$1,0)-'Purchased Items'!F348),0)

and values are as per the screenshot:

enter image description here

Also you can check the Output I have stored in datatable to check the value:

enter image description here


Solution

  • Just keep updated on this post that I have found another library IronXL. When I use it then this problem is solved but one issue with this IronXL that that it will work locally but if you deploy your code in production then code will stop working & need to purchase the license for use in production