现在的位置: 首页 > 综合 > 正文

C#中判断上传类型为Excel,03和07版的链接字符串

2012年07月30日 ⁄ 综合 ⁄ 共 567字 ⁄ 字号 评论关闭

有时候经常用到,做个记录

判断上传文件为Excel:

if ((this.FileUpload1.PostedFile.ContentType == "application/vnd.ms-excel") || (this.FileUpload1.PostedFile.ContentType == "application/ms-excel") || (this.FileUpload1.PostedFile.ContentType== "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"))
{}

03版Excel链接字符串:

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(savePath) + ";Extended Properties='Excel 8.0;HDR=No;IMEX=1'";

07以上版Excel链接字符串:

strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath(savePath) + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';";

 

抱歉!评论已关闭.