下面是将msflexgrid中的数据导出到excel的代码:
Dim XlApp As Excel.Application
Dim XlBook As Excel.WorkbookDim XlSheet As Excel.Worksheet
Dim i As Integer
Dim j As Integer
Set XlApp = CreateObject("Excel.Application") '初始化
Set XlBook = XlApp.Workbooks.Add
Set XlSheet = XlBook.Worksheets(1)
For i = 0 To MSFlexGrid1.Rows - 2 '将msflexgrid1中的数据写入excel表格中
For j = 0 To 4
XlSheet.Cells(i + 1,j + 1) = MSFlexGrid1.TextMatrix(i,j)
Next j
Next i
XlApp.Visible = True '填写完毕后显示excel表格 原文链接:https://www.f2er.com/vb/260984.html