关于MSFlexGrid的问题。(在线等待)

yaojr21 2002-07-18 01:33:49
哪位大虾知道如何打印MSFlexGrid控件显示的全部数据,请多多指教,小弟不甚感激!
...全文
64 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Do_Better 2002-07-19
  • 打赏
  • 举报
回复
不错!
sxshao 2002-07-19
  • 打赏
  • 举报
回复
使用 vsflexgrid 显示数据,直接发到 Vsview 中 打印 了
keyterxian 2002-07-18
  • 打赏
  • 举报
回复
例子:在你的FORM中加入,一个名为MSFlexGrid1 的MSFlexGrid1 控件和一个名为command1的command控件

Sub command1_click(MSFlexGrid1 As MSFlexGrid)
On Error GoTo ErrHandler
Dim EXCELApp As Excel.Application
Dim EXCELWorkBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Dim rows, cols As Integer
Dim Irow, hCol, Icol As Integer
Dim New_Col As Boolean


If MSFlexGrid1.rows <= 1 Then
MsgBox "还没有数据记录", vbInformation, App.Title
Exit Sub
End If

Set EXCELApp = CreateObject("Excel.application")
Set EXCELWorkBook = EXCELApp.Workbooks.Add
Set xlSheet = EXCELWorkBook.Sheets(1)
Dim New_Column As Boolean

With MSFlexGrid1
rows = .rows
cols = .cols
Irow = 0
Icol = 1
For hCol = 0 To cols - 1
For Irow = 1 To rows
EXCELApp.Cells(Irow + 1, Icol).Value = .TextMatrix(Irow - 1, hCol)
Next Irow
Icol = Icol + 1
Next hCol
End With
'xlsheet.Range(xlsheet.Cells(2, 0), xlsheet.Cells(rows, cols - 1)).Borders.LineStyle = xlContinuous

EXCELApp.rows(2).Font.Bold = True
EXCELApp.Cells.Select
EXCELApp.Columns.AutoFit
EXCELApp.Cells(1, 1).Select
EXCELApp.Application.Visible = True
'EXCELApp.Sheets.PrintPreview
Set EXCELWorkBook = Nothing
Set EXCELApp = Nothing
MSFlexGrid1.SetFocus
' MsgBox "Data has been successfully copied to Excel. ", vbInformation, "Success"
Exit Sub
ErrHandler:
MsgBox "报表错误", vbInformation, "报表错误"
End Sub
netfor2000 2002-07-18
  • 打赏
  • 举报
回复
for i = 0 to grid.rows-1
for j = 0 to grid.cols-1
grid.row = i
grid.col = j
print grid.text
next j
next i
yaojr21 2002-07-18
  • 打赏
  • 举报
回复
谢谢!
Jonah 2002-07-18
  • 打赏
  • 举报
回复
for i = 0 to grid.rows
for j = 0 to grid.cols
grid.row = i
grid.col = j
print grid.text
next j
next i

7,787

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧