i try to use ms interopt to import data from excel file, i have install Microsoft office 2007 in my computer and working fine, when i use the code in another computer have Microsoft office 2019 installed i face this error, i install
Microsoft Access Database Engine 2010 Redistributable
but not fix the problem , also i search fro link of 2007 System Driver Data Connectivity Component, but i cannot find any one, and Microsft has remove the file, this is my code:
using System.Data.OleDb;
OleDbConnection conn=null;
DataTable ExcelDataTables = null;
try {
conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFilePath + ";Extended Properties=" + "\"Excel 12.0 Xml;HDR=YES;IMEX=1\"";
conn.Open();
ExcelDataTables = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
String[] ExcelSheetNames = new String[ExcelDataTables.Rows.Count];
int i = 0;
// Add the sheet name to the string array.
foreach (DataRow row in ExcelDataTables.Rows)
{
ExcelSheetNames[i] = row["TABLE_NAME"].ToString();//.Replace("'","").Replace("$", "");
i++;
}
// Loop through all of the sheets if you want too...
/*for (int j = 0; j < excelSheets.Length; j++)
{
// Query each excel sheet.
}*/
conn.Close();
conn = null;
LSTBox_ExcelSheetNames.DataSource = ExcelSheetNames;
}
catch (Exception ex)
{
if (conn != null)
conn.Close();
conn = null;
ExcelDataTables = null;
FRM_MSG f = new FRM_MSG();
f.ShowDLG(" ",
ex.Message + "\n" + ex.StackTrace.ToString(),
FRM_MSG.MSGIcon.Error,
FRM_MSG.BTNS.One,
new string[] { "Ok" });
}
please give me a link to 2007 System Driver Data Connectivity Component.