OLEDB方式:
Provider= Microsoft.Jet.OLEDB.4.0; Data Source= C:\MyExcel.xls; Extended Properties= "Excel 8.0;HDR=Yes;IMEX=1";
"HDR=Yes;" indicates that the first row contains columnnames, not data.
"HDR=No;" indicates the opposite.
"IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.
加上IMEX=1这个属性,Excel单元格的值就会以文本型读取,避免由于数据类型不一致导致某些值读不出来的问题
Provider= Microsoft.Jet.OLEDB.4.0; Data Source= C:\MyExcel.xls; Extended Properties= "Excel 8.0;HDR=Yes;IMEX=1";
"HDR=Yes;" indicates that the first row contains columnnames, not data.
"HDR=No;" indicates the opposite.
"IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.
加上IMEX=1这个属性,Excel单元格的值就会以文本型读取,避免由于数据类型不一致导致某些值读不出来的问题