本文介绍了对象中的C#.NET Excel问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在c#.net中遇到了有关Excel的问题.我的应用程序是简单地从excel读取数据并放入sql dbase.我用vb.net开发的.没有问题.但是当我更改为c#.net时,我遇到了有关对象变量的问题.我的vb.net代码在这里:

Hi all,

I got an issue about Excel in c#.net. my application is simple read data from excel and put into the sql dbase. i developed with vb.net. there is no issue. but when i change to c#.net i faced an issue about object variable. my vb.net code is here:

Dim obj as Object

For intInc as integer=2 to xlRange.Rows.Count
       obj = xlRange.Cells(i,1)
       Dim strValue as string = obj.value
       SaveInDbase(strValue)
Next



但是当我更改为c#.net时.该对象没有.value.所以我应该如何从对象变量中获取值.我的C#代码在这里:



but when i change to c#.net. the object don''t have .value. so how should i take value from object variable.my c# code is here:

Object obj=null;
for (int i=1;i<xlrange.rows.count;i++){>
        obj = xlRange.Cells[i,1];
        String strValue = obj.value;
        SaveInDbase(strValue);
}



我还把obj.ToString(),obj作为字符串,(string)obj.但仍然无法正常工作.我只有"System .__ comobject" :(

请帮助我,并给我建议,在此先谢谢您.



i also put obj.ToString(),obj as string,(string)obj. but still cannot work. i got "System.__comobject" only :(

please help me and give me suggestion , thanks in advance.

推荐答案


这篇关于对象中的C#.NET Excel问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 21:48
查看更多