Excel文件中有一个坐标点,设置格式类型为:用户定义=yyyy/mm/dd
在C#中               OleDbConnection oleCn = new OleDbConnection();
                    oleCn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                        "Data Source=" + m_strExcelFileName + ";" +
                        "Extended Properties=\"Excel 8.0;" +
                        "HDR=YES;IMEX=1\"";
                    oleCn.Open();                    OleDbDataAdapter da = new OleDbDataAdapter(strSQL, oleCn);                    DataSet ds = new DataSet();                    da.Fill(ds, strTblName);
                    this._dtCurrentTable = ds.Tables[strTblName];然后通过dtCurrentTable.Rows[j][8].ToString()读取数值问题来了:该Excel文件打开的情况下,读出来的数值是个“39437”
关闭的情况下是:“2007/12/21”
为什么会出现这种情况,本质上应该如何解决if else和利用Excel进程的不需要,谢谢

解决方案 »

  1.   

    I tried your code. It is always displaied in date format no matter excel file opening or close.
    Don't why is not working on your PC.up..
      

  2.   

    Excel中使用的Office专用DateTime格式.你可以先使用DateTime中的OfficeDate来读取后转为系统使用的DateTime格式.
      

  3.   

    使用DateTime.FromOADate();来完成从Word、Excel等Office文档中读取日期
      

  4.   

    回5楼,我用的就是你说地这个方法,
    但是因为读取出来的数据有2中可能,所以要进行if else判断。这是我不想要的
    我想知道为什么会出现这种情况。如何能解决它,而不是就问题解决问题。谢谢。
      

  5.   

    I   tried   your   code.   It   is   always   displaied   in   date   format   no   matter   excel   file   opening   or   close. 
    Don't   why   is   not   working   on   your   PC. up..
    ---------------------------
    我糊涂了,我的电脑的确存在这个问题。等晚上我回家再看看。电脑应该是没什么问题的。