
Hello,
I'm trying to get the value of some cells where there is a formula that return integers and decimals.
After calculate the formula I have no problem to get integer values, I have 0 when the the cells work with decimal values.
Here is an extract of my code:
for (int i = 6; i < 10; i++)
{
ws.Cells[posY + 1, posX + i + 1].Formula = "IFERROR(SUMPRODUCT(" + getExcelColumnName(posX + 1 + i) + "" + (posY + 2) + ": " + getExcelColumnName(posX + 1 + i) + "" + (posY + 25) + ", " + getExcelColumnName(posX + 2) + "" + (posY + 2) + ": " + getExcelColumnName(posX + 2) + "" + (posY + 25) + ")/" + getExcelColumnName(posX + 2) + "" + (posY + 1) + ", 0)";
ws.Cells[posY + 1, posX + i + 1].Calculate();
}
using (var range = ws.Cells[posY + 1, posX + 6 + 1, posY + 25, posX + 15])
{
range.Style.Numberformat.Format = "0.00";
}
for (int x = 0; x < 14; x++)
{
Console.WriteLine(ws.Cells[posY + 1, posX + x + 1].Value);
}
I've tried to parse to double, to work with strings, I don't know what to do more.
Did anyone of you face a similar problem?
Thanks, in advance.



Found the issue by myself: FORMULAS MUST NOT CONTAIN SPACES!!!!!! If you look in the code i had ...+ ": " + ... (a space after the semicolon).
Hope this can help.

