lundi 3 avril 2017

If statement doesn't check the condition for an excel cell value in c#

I have the code like above

if (worksheet.UsedRange.Cells[rowvalue,columnvalue].Value2.ToString() == "0")
    {
      Statement1
      Statement2
    }

It doesn't recognize the condition i think because it is number. The point is that in excel the number is stored as text. enter image description here

I tried with .text but it doesn't check the condition anyway. If i put the same condition for a cell that contains text, like if (worksheet.UsedRange.Cells[rowvalue,columnvalue].Text == "sometext") it recognize the condition. What can i do at this point? Any Idea?

Aucun commentaire:

Enregistrer un commentaire