用DATA控件读取Excel时产生数值字段溢出错误,并且错误也没有规律可循,24这样的值也报溢出,单元格格式设为文本或数值或常规都试过了,不管用。用ACCESS链接这个EXCEL表,打开这个表查看,发现代码不能读取的地方,被替换成了这种东西:#数字!。好象是JET引擎根本就读不出。代码如下:
    datXls.Connect = "Excel 8.0;"
    datXls.DatabaseName = txtFile.Text
    datXls.RecordsetType = 1
    datXls.RecordSource = "Select * from [Sheet1$]"
    datXls.Refresh
        
    Dim i As Integer
    With datXls.Recordset
        While Not .EOF
            For i = 0 To .Fields.Count - 1
                Debug.Print .Fields(i).Name & vbTab & .Fields(i).Value
            Next
            .MoveNext
        Wend
        .Close
    End With

解决方案 »

  1.   

    Don't know the exact cause.  But JET Engine is kind of obsolete.  So my advice is to try ADO instead and see if that helps.
      

  2.   

    You might also want to check if the problem cells are "calculated cells".  A calculated cell is a one that refers to other cells.
      

  3.   

    Thanks for your attention!
      firstly,the problem cells are not "calculated cells";secondly,I try it by ADO connection,but find it can not work correcttly,the ADO Connection String is incorrect,and I do not want to use ODBC Connection.What I can do next?
      Do you mind give me your EMAIL so I can send the problem EXCEL file to you?