Private Sub Form_Load() Data1.DatabaseName = App.Path & "\msdb.mdb" Text1.Text = Data1.DatabaseName End Sub Private Sub Command1_Click() Dim i As Integer, j As Integer Dim newxls As Excel.Application Dim newbook As Excel.Workbook Dim newsheet As Excel.Worksheet Set newxls = CreateObject("Excel.Application") '创建excel应用程序,打开excel2000 newxls.Visible = True Set newbook = newxls.Workbooks.Add '创建工作簿 Set newsheet = newbook.Worksheets(1) '创建工作表 'If Not Data1.Recordset.EOF Then Data1.Recordset.MoveFirst For i = 0 To Data1.Recordset.RecordCount - 1 For j = 0 To Data1.Recordset.Fields.Count - 1 DBGrid1.Row = i DBGrid1.Col = j newsheet.Cells(i + 1, j + 1) = DBGrid1.Text Next j Next i End Sub Private Sub Command2_Click() End End Sub
Data1.DatabaseName = App.Path & "\msdb.mdb"
Text1.Text = Data1.DatabaseName
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim newxls As Excel.Application
Dim newbook As Excel.Workbook
Dim newsheet As Excel.Worksheet
Set newxls = CreateObject("Excel.Application") '创建excel应用程序,打开excel2000
newxls.Visible = True
Set newbook = newxls.Workbooks.Add '创建工作簿
Set newsheet = newbook.Worksheets(1) '创建工作表
'If Not Data1.Recordset.EOF Then Data1.Recordset.MoveFirst
For i = 0 To Data1.Recordset.RecordCount - 1
For j = 0 To Data1.Recordset.Fields.Count - 1
DBGrid1.Row = i
DBGrid1.Col = j
newsheet.Cells(i + 1, j + 1) = DBGrid1.Text
Next j
Next i
End Sub
Private Sub Command2_Click()
End
End Sub