2011-05-16 133 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;"; 
    }