c# Error: “Could Not Find Installable ISAM” in converting Excel file into .CSV file -
i'm working on project able convert excel files .csv file, think there problems in c# code generating , error message could not find installable isam, please me sort out problem.
code:
if (dlgone.filename.endswith(".xlsx")) { strconn = @"provider=microsoft.ace.oledb.12.0;data source=" + srcfile + ";extended properties=\"excel 12.0;\""; } if (dlgtwo.filename.endswith(".xls")) { strconn = @"provider=microsoft.jet.oledb.4.0;data source=" + srcfile + ";extended properties=\"excel 1.0;hdr=yes;imex=1\""; } oledbconnection conn = null; conn = new oledbconnection(strconn); conn.open(); <------------ throw exception
in debug mode application throws exception (line: conn.open();
) searched internet , found have put data source
between 1 cotes doesn't work in case.
both of connection strings wrong.
for .xlsx, should be:
strconn = @"provider=microsoft.ace.oledb.12.0;data source=" + srcfile + ";extended properties=\"excel 12.0 xml;hdr=yes;imex=1\";";
(note xml part, hdr=yes indicate file has headers, imex=1 treat data text , repositioned semi-colon. need different connection strings .xlsm , .xlsb files - see here)
for .xls, should be:
strconn = @"provider=microsoft.jet.oledb.4.0;data source=" + srcfile + ";extended properties=\"excel 8.0;hdr=yes;imex=1\";";
(note change excel 1.0 excel 8.0 , addition of semi-colon @ end)
Comments
Post a Comment