xlSheet.Cells(j + 1, 3) = Adodc1.Recordset.Fields(2) xlSheet.Cells(j + 1, 4) = Adodc1.Recordset.Fields(3) xlSheet.Cells(j + 1, 5) = Adodc1.Recordset.Fields(4) xlSheet.Cells(j + 1, 6) = Adodc1.Recordset.Fields(5) xlSheet.Cells(j + 1, 7) = Adodc1.Recordset.Fields(6) xlSheet.Cells(j + 1, 8) = Adodc1.Recordset.Fields(7) xlSheet.Cells(j + 1, 9) = Adodc1.Recordset.Fields(8) xlSheet.Cells(j + 1, 10) = Adodc1.Recordset.Fields(9) xlSheet.Cells(j + 1, 11) = Adodc1.Recordset.Fields(10) xlSheet.Cells(j + 1, 12) = Adodc1.Recordset.Fields(11) xlSheet.Cells(j + 1, 13) = Adodc1.Recordset.Fields(12) xlSheet.Cells(j + 1, 14) = Adodc1.Recordset.Fields(13) xlSheet.Cells(j + 1, 15) = Adodc1.Recordset.Fields(14) Adodc1.Recordset.MoveNext Next
SaveFile = "d:\1.xls" '你可以在此修改保存的文件名称 If Dir(SaveFile) <> "" Then Kill SaveFile
xlBook.SaveAs FileName:=SaveFile '保存工作表,结束时一定别忘了保存
xlBook.Close (True) '关闭工作簿 这里的True表示退出时保存修改 xlApp.Quit '结束EXCEL对象
Set xlApp = Nothing '释放xlApp对象 MsgBox "文件已成功导出到" & SaveFile End Sub
Private Sub Command5_Click() Form3.Hide Form2.Show End Sub
Private Sub Form_Load()
Adodc1.RecordSource = "select * from 员工基本信息表 where 员工编号 like '%" & Text2.Text & "%' and 姓名 like '%" & Text1.Text & "%'and 婚姻状况 like '%" & Combo1.Text & "%'and 性别 like '%" & Combo6.Text & "%' and 职位 like '%" & Combo2.Text & "%' and 政治面貌 like '%" & Combo3.Text & "%' and 所在部门 like '%" & Combo5.Text & "%'and 学历 like '%" & Combo4.Text & "%' " Combo1.AddItem "已婚" Combo1.AddItem "未婚" Combo2.AddItem "总经理" Combo2.AddItem "副总经理" Combo2.AddItem "部长"