I have some problem in using If statement using EPPlus. My formula in Excel is like this :
=IF(AND(L18<>0,LEFT(E18,1)="Z"),2,0)
And I code in C# is like this
cart.Cells[5 + i, 9].Formula = "IF(AND(L" + (5 + i) + "<> 0,LEFT(E" + (5 + i) + ",1)= Z),2,0)";
The problem is in LEFT(E18,1)= Z. If I use "" sign, C# will read it as inserting some integer. But if I don't use "", Excel will not read it as string. Can anyone help me to solve that ?
you have to escape the internal string quotes beside the Z, i.e. instead of "Z"
you should use \"Z\"
as following:
cart.Cells[5 + i, 9].Formula = "IF(AND(L" + (5 + i) + "<> 0,LEFT(E" + (5 + i) + ",1)= \"Z\"),2,0)";