将数据库的内容输出到EXCEL为什么不好使?
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim newxls As New Excel.Application
Dim newbook As Excel.Workbook
Dim newsheet As Excel.Worksheet
Set newxls = CreateObject("Excel.Application")
newxls.Visible = True
Set newbook = newxls.Workbooks.Add
Set newsheet = newbook.Worksheets(1) 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

