我的应用程序基本上接受一个 excel 文件并将数据上传到我的数据库,该数据库曾经使用以下代码与 Excel 2010 完美配合。但是,我们将系统更新到 Excel 2016 并且由于某种原因停止工作,请您协助我对我的代码进行哪些更新。
这是当前要连接的代码:
openFileDialog1.ShowDialog();
var fileName = string.Format(openFileDialog1.FileName);
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(fileName, 1, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, null, false);
var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + "; Extended Properties=Excel 12.0;", fileName);