我用ADO连接Excel文件。。
Excel文件里有一些字段大部分是数字来的
不过个别有中文字,读出时为何认为是float型的呢?
改成wideString都不成呀。。会自动改为float型的字段内容如下
 政治
  60
  90
补考60    ---------------就是这个读不到,它读成空的,如果用acc打开也是读不了呀!
  70
  80

解决方案 »

  1.   

    可能这个字段被Excel当成数字类型了,
    你用Excel打开该文件,将这一列的属性强制指定为字符串属性试试看.
      

  2.   

    to: stargazer(星空守望者) 
    已试过设成文本的,还是不行。。
      

  3.   

    你是怎么读的呀?不要读完再改为widestring,而是要用widestring类型去读.
      

  4.   

    to: zleeway(杂草) 
    我在设计时导入数据,它自动设为float,
    我将它改为widestring,但一会它就自动变为float呀?
    你说用widestring去读。
    那应该怎样读呢?thx
      

  5.   

    在delphibbs上得到了答案。。
    设Extended Properties成为Excel 8.0;HDR=YES;IMEX=1
    不过还是有问题。。这是在.net的文档里找到的。Data TypesUnlike a traditional database, there is no direct way to specify the data types for columns in Excel tables. Instead, the OLE DB provider scans a limited number of rows in a column to "guess" the data type for the field. The number of rows to scan defaults to eight (8) rows; you can change the number of rows to scan by specifying a value between one (1) and sixteen (16) for the MAXSCANROWS setting in the extended properties of your connection string.