vb中将数据导出到excel表格中

前端之家收集整理的这篇文章主要介绍了vb中将数据导出到excel表格中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面是将msflexgrid中的数据导出到excel的代码

Dim XlApp As Excel.Application

Dim XlBook As Excel.Workbook
Dim 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

猜你在找的VB相关文章