救助 怎样用vb6编写对excel表单元格的查询
在电脑上没有数据库前下,想做一个vb6对excel表的查询功能。查询列:姓名或列电话号码,当符合查询条件时,会显示出来,或可以提取出来。请大师们给点代码提示?[此贴子已经被作者于2017-3-19 19:10编辑过]
Dim SQL As String Public rs As ADODB.Recordset Dim strSQL As String CommonDialog1.Filter = "电子表格文件(.xls)|*.xls" CommonDialog1.DialogTitle = "请选择要导入的文件" CommonDialog1.ShowOpen SQL = "INSERT INTO Family SELECT * FROM OpenRowSet('microsoft.jet.oledb.4.0','Excel 14.0;HDR=Yes;database=" & CommonDialog1.FileName & " ;','select * from [Sheet1$] ')" Set rs = Selectsql(SQL) Conn.Execute SQL, , adExecuteNoRecords Conn.Close
Dim xlApp As Excel.Application Dim xlBook As Excel.WorkBook Dim xlSheet As Excel.Worksheet Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象 Set xlBook = xlApp.Workbooks.Open("文件名") '打开已经存在的EXCEL工件簿文件 xlApp.Visible = True '设置EXCEL对象可见(或不可见) Set xlSheet = xlBook.Worksheets("表名") '设置活动工作表 val1=xlSheet.Cells(row, col)