2011-05-16 137 views
0

hello有没有办法从excel 2007文件导入数据?它与Excel 2003工作,但我在2007年尝试时出现错误是否有任何我应该遵循的参考,请咨询我还是新的@这个。从excel 2007导入数据ASP.net

回答

0

连接字符串将有条件为您的办公室2007年和2003年支持

if (System.IO.Path.GetExtension(fup.FileName) == ".xls") 
    { 
     connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/upload/temp/File.xls") + "; Extended Properties=Excel 8.0;"; 
    } 
    else if (System.IO.Path.GetExtension(fup.FileName) == ".xlsx") 
    { 
     connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("~/upload/temp/File.xlsx") + "; Extended Properties=Excel 12.0;"; 
    }