请教各位:
我用c#开发的windows应用程序,我想读取excel里的内容,但是有个字段是货币格式的,就是读取不到,为什么啊?有什么办法可以取到值呢?
string strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+sopath+";Extended Properties=excel 8.0";
conn = new OleDbConnection(strconnection);
conn.Open();
String sql ="select * from [SAPBW_DOWNLOAD$]";
OleDbCommand cmd = new OleDbCommand(sql,conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
for (int i=0;i<dataset.Tables[0].Rows.Count-1;i++)
{
.....
dataset.Tables[0].Rows[i][5];
.....
}
dataset.Tables[0].Rows[i][5]==null,为什么呢?

解决方案 »

  1.   

    因为本来就没有存,是format显示出来的。
      

  2.   

    shleo,是什么意思?可否详细说说?
      

  3.   

    最好在做EXCEL时所有的单元格都用文本格式
      

  4.   

    Alvin709,请问我怎么把excel的所有单元格格式化呢?有没有代码呢?我就知道c#访问excel用string strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+sopath+";Extended Properties=excel 8.0"; 
    conn = new OleDbConnection(strconnection); 
    conn.Open(); 
    String sql ="select * from [SAPBW_DOWNLOAD$]"; 
    怎么读取到excel的cell呢?
      

  5.   

    看看这个!!
    http://topic.csdn.net/u/20080620/12/66d01de0-84a4-4c57-844b-d0b7553720b1.html