请问如何用数据库技术DAO、ADO直接打开Excel.xls文件?急!
请问如何用数据库技术DAO、ADO直接打开Excel.xls文件?急!
不用ODBC方法,而是直接打开文件!
[解决办法]
vb.net 的写法希望对你有帮助
System.Data.OleDb.OleDbConnection OleExcel = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source=" + openFileDialog1.FileName + ";Extended Properties=Excel 8.0;");
System.Data.OleDb.OleDbDataAdapter OleCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Ôôé$]", OleExcel);
DataTable[] dtRead = new DataTable[4];
dtRead[0] = new DataTable();
OleCommand.Fill(dtRead[0]);
[解决办法]
dim ac_excel as new adodb.connectiondim rs as new adodb.recordsetdim strsql as string'建立与EXCEL文件的连接With ac_Excel .CursorLocation = adUseClient If .State = adStateOpen Then .Close .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\aa.xls;Extended Properties=Excel 8.0;HDR=Yes;IMEX=1" .Open .CommandTimeout = 0End Withstrsql=" select * from sheet1$ "if rs.state<>adstateclosed then rs.closers.open strsql,ac_excel,adopenkeyset,adlockreadonly
[解决办法]
帮顶。