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

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

判断上传文件为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';";

 

posted @ 2013-05-21 15:51  雪空子  阅读(399)  评论(0编辑  收藏  举报