导入EXCEL文件时区分03和07版的0307版

来源:互联网 发布:java排序效率最高 编辑:程序博客网 时间:2024/05/22 02:04
           // string fPath = this.excelFile.PostedFile.FileName;//获得要导入的文本文件                                           string extName = excelFile.Substring(excelFile.LastIndexOf(".") + 1);//获得文件的扩展名                string strConn;            if (extName == "xls")            {                strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + excelFile + ";" + "Extended Properties=Excel 8.0;";            }            else            {                strConn = "Provider=Microsoft.ACE.OLEDB.12.0;"+"Data Source=" + excelFile + ";" + "Extended Properties=Excel 12.0;";            }