在线等,MsflexGrid的问题,

chinagkk1984 2004-11-02 12:05:35
如何把MsflexGrid里的内容输出到Execel里,希望能具体给一个例子,在线等当中
...全文
67 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
chinagkk1984 2004-11-02
好了,试了,可以了,OK
回复
sloven 2004-11-02
晚了,上面已经给出了。
回复
chinagkk1984 2004-11-02
是不是要什么控件的啊!
回复
outorenter 2004-11-02
Private Sub Command1_Click()
'导出
Dim Mrows, Mcols As Integer
Dim xlApp As Object
Dim xlWb As Object
Dim xlWs As Object
Dim i, j As Long
Mrows = MSHFlexGrid1.Rows
Mcols = MSHFlexGrid1.Cols

On Error GoTo err

Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets("Sheet1")

xlApp.Visible = True
xlApp.UserControl = True

For i = 1 To Mrows
For j = 1 To Mcols - 1
xlWs.Cells(i, j).Value = MSHFlexGrid1.TextMatrix(i - 1, j)
Next
Next

xlApp.Selection.CurrentRegion.Columns.AutoFit
xlApp.Selection.CurrentRegion.Rows.AutoFit

Set xlWs = Nothing
Set xlWb = Nothing
Set xlApp = Nothing

Exit Sub

err:
MsgBox "不能导出,请检查是否正确安装了Microsoft Excel", vbExclamation, "LBWU"
End Sub
回复
发动态
发帖子

1180

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
社区公告
暂无公告