c# - Unable to Open an Excel file using System.Data.OleDb.OleDbConnection -
this question has answer here:
iam trying open xlsx file (so can create datatable ) iam using the below code.
system.data.oledb.oledbconnection oledbcon; system.data.oledb.oledbdataadapter oledbdataad; oledbcon = new system.data.oledb.oledbconnection("provider=microsoft.jet.oledb.4.0;data source='" + filepath + "';extended properties=excel 8.0;");
but when file path contains file extension xlsx , error "external table not in expected format."
above code works fine when file of extention xls.
do have change connection string ?
any ?thanks in advance.
changed connection string to
public static string connstr = "provider=microsoft.ace.oledb.12.0;data source=" + path + ";extended properties=excel 12.0;";
Comments
Post a Comment