我使用以下代码上传excel文件到VB.NET系统。这是为office 2007工作的。但不是office2010。如何更改所有office版本的工作代码?
If (strFileType.Trim() = ".xls") Then
connectionString = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", target + "\" + FileUpload1.FileName)
Else
connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", target + "\" + FileUpload1.FileName)
'"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strNewPath + ";Extended Properties="Excel 12.0;HDR=Yes;IMEX=2"";
End If
从
修改else部分的语句connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", target + "\" + FileUpload1.FileName)
connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1;""", target +
"\" + FileUpload1.FileName)
修改后的Extended Properties