Dim i, j As Integer
Dim xls As New Excel.Application
Dim book As Excel.Workbook
Dim sheet As Excel.Worksheet
xls.Visible = True
Set book = xls.Workbooks.Add
Set sheet = book.Worksheets(1)
For i = 0 To AdodcData.Recordset.RecordCount - 1
For j = 0 To 7
DataGrid1.Row = i
DataGrid1.Col = j
sheet.Cells(2, j + 1) = DataGrid1.Columns(j).Caption
sheet.Cells(i + 3, j + 1) = DataGrid1.Text
Next j
Next i
执行过程中,输出一部分之后,会碰到执行到这一句报错:DataGrid1.Row = i,提示输出行错误,为什么阿,应该怎么解决?
Dim xls As New Excel.Application
Dim book As Excel.Workbook
Dim sheet As Excel.Worksheet
xls.Visible = True
Set book = xls.Workbooks.Add
Set sheet = book.Worksheets(1)
For i = 0 To AdodcData.Recordset.RecordCount - 1
For j = 0 To 7
DataGrid1.Row = i
DataGrid1.Col = j
sheet.Cells(2, j + 1) = DataGrid1.Columns(j).Caption
sheet.Cells(i + 3, j + 1) = DataGrid1.Text
Next j
Next i
执行过程中,输出一部分之后,会碰到执行到这一句报错:DataGrid1.Row = i,提示输出行错误,为什么阿,应该怎么解决?
http://www.microsoft.com/china/community/Column/32.mspx
For 1 = 1 To 8
DataGrid1.Row = i
DataGrid1.Col = j
sheet.Cells(2, j + 1) = DataGrid1.Columns(j).Caption
sheet.Cells(i + 3, j + 1) = DataGrid1.Text
Next j
Next i