开发者

Comparing cell value to a textbox.text value C#

long story short 开发者_开发技巧I have written a comparison for excel iterationh through rows in C# :

if(ws.Cells[i, "C"].ToString() == TextBox12.Text)

which turns out to be throwing an com hresult exception. What is the right way to do this comparison? I've done extensive searches on the internet but nothing that suits me. Help needed!


Taking the .ToString() method of the ws.Cells[i,"C"] object returns the type System._ComObject. You want ws.Cells[i,"C"].Value.ToString(). I tested it, and it found the two were equal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜