首页 > 学院 > 开发设计 > 正文

C#连接Excel提示“外部表不是预期的格式”

2019-11-06 08:09:49
字体:
来源:转载
供稿:网友

Office2003(Microsoft.Jet.Oledb.4.0)string strConn = string.Format("PRovider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'", strExcelFileName);

Office2007(Microsoft.ACE.OLEDB.12.0)string strConn = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'", strExcelFileName);

Office2010(Microsoft.ACE.OLEDB.12.0)string strConn = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0;HDR=Yes;IMEX=1;'", strExcelFileName);

还要一个就是“HDR=Yes”这个问题,如果HDR的值是Yes,那么第一行是被当做列名的,不会被导入。只有为“No”才可以被当做数据导入。


上一篇:算法作业2

下一篇:希尔排序

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表