Dim i_row as integer
dim i_col As Integer
'创建EXCEL应用对象,以及相关的EXCEL对象并引用
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
Set xlbook = xlapp.workbooks.Add
Set xlsheet = xlbook.worksheets(1)
i_row = 0
Do While i_row < mshflexgrid.Rows
For i_col = 0 To mshflexgrid.Cols - 1
xlsheet.cells(i_row, i_col + 1) = mshflexgrid.TextMatrix (i_row, i_col)
Next i_col
i_row = i_row + 1
Loop
dim i_col As Integer
'创建EXCEL应用对象,以及相关的EXCEL对象并引用
Set xlapp = CreateObject("excel.application")
xlapp.Visible = True
Set xlbook = xlapp.workbooks.Add
Set xlsheet = xlbook.worksheets(1)
i_row = 0
Do While i_row < mshflexgrid.Rows
For i_col = 0 To mshflexgrid.Cols - 1
xlsheet.cells(i_row, i_col + 1) = mshflexgrid.TextMatrix (i_row, i_col)
Next i_col
i_row = i_row + 1
Loop
这个就是DATAGRID的行啊mshflexgrid.Cols 是它的列啊
里面有篇文章