I'm trying to add a formula to a cell in multiple rows in Excel through C#.
What i'm trying to achieve with the formula is to SUM
all the cells which does not contain the string N/A
, in column D to S
in every row.
This is the formula i'm trying to add:
=SUMIF(DX:SX,"<>N/A")
(In the example above i changed the actual row number with X)
So i'm looping through the rows and doing this:
foreach (var row in rows)
{
ws.Cells[row, 2].Formula = string.Format("=SUMIF(D{0}:S{0},\"<>N/A\")", row + 1);
}
Here I get the exception:
System.ArgumentException : Failed to parse: =SUMIF(D2:S2,"<>N/A"). Error: Unsupported function: SUMIF.For list of supported functions consult GemBox.Spreadsheet documentation.
I've also tried to add the Swedish version of the formula which is:
=SUMMA.OM(DX:SX;"<>N/A")
(In the example above i changed the actual row number with X)
and here i get the exception:
System.ArgumentException : Failed to parse: =SUMMA.OM(D2:S2;"<>N/A"). Error: Not expected: SUMMA
The weirdest part of this is that if i manually enter the swedish formula in the cell in Excel, it works.
Appreciate any help i can get, thank you so much.