请问MsFlexGrid带打印预览吗?

sonyge 2004-04-30 12:40:44
请问MsFlexGrid带打印预览吗?
...全文
82 7 点赞 打赏 收藏 举报
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
suntt 2004-05-10
用Excel预览是不是得show出Excel才行,不能够隐藏Excel主界面?
  • 打赏
  • 举报
回复
Wings5427 2004-05-10
五一放假,回复晚了。
Showdate类只是调用一个存储过程取得服务器时间,没什么特殊用处。
  • 打赏
  • 举报
回复
wumylove1234 2004-04-30
Dim gdate As New Showdate

朋友,把showdate这个类的代码也给出来啊~
  • 打赏
  • 举报
回复
wumylove1234 2004-04-30
好东西,正好要用到~收~
  • 打赏
  • 举报
回复
Wings5427 2004-04-30
我写的一个类,你参考一下
'通过Excel打印报表(title():报表的主标题和附标题,msh:网格控件,filepath:excel模板文件的路径(空excel表),password:模板文件的密码,preview:是否要打印预 0:不预览)
Public Function Printing(title() As String, ByRef msh As Object, filepath As String, password As String, Optional preview As Long = 0) As Boolean
Dim printvalue() As String
Dim i As Long
Dim j As Long
Dim ex As New Excel.Application
Dim exwbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Dim gdate As New Showdate
On Error GoTo printErr
If Dir(filepath) = "" Then GoTo printErr
ReDim printvalue(msh.Rows, msh.cols)
'MsgBox msh.Rows & "," & msh.Cols
If Printers.count = 0 Then
MsgBox "打印机不存在,请安装打印机", , "提示"
Exit Function

End If
For i = 0 To msh.Rows - 1
For j = 0 To msh.cols - 1
printvalue(i, j) = msh.TextMatrix(i, j)
Next j
Next i

Set ex = CreateObject("excel.application")
Set exwbook = ex.Workbooks.Open(filepath, , , , password, password, True)
Set exsheet = exwbook.Worksheets(1)
' If P.ShowPrinter = True Then
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).MergeCells = True
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).HorizontalAlignment = xlCenter
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).VerticalAlignment = xlBottom
ex.Range(ex.Cells(2, 1), ex.Cells(2, msh.cols)).MergeCells = True
ex.Range(ex.Cells(2, 1), ex.Cells(2, msh.cols)).HorizontalAlignment = xlCenter
ex.Range(ex.Cells(2, 1), ex.Cells(2, msh.cols)).VerticalAlignment = xlBottom
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).Font.Size = 20
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).Font.Bold = True
ex.Range(ex.Cells(1, 1), ex.Cells(3, msh.cols)).Interior.Color = &HC0C0C0
ex.Range(ex.Cells(3, 1), ex.Cells(msh.Rows + 2, 1)).Interior.Color = &HC0C0C0
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).Interior.PatternColorIndex = xlAutomatic
ex.Range(ex.Cells(1, 1), ex.Cells(msh.Rows + 1, 1)).Interior.PatternColorIndex = xlAutomatic
ex.Cells(1, 1) = title(0)
ex.Cells(2, 1) = title(1)
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).Font.Size = 16
ex.Range(ex.Cells(1, 1), ex.Cells(1, msh.cols)).Font.Bold = True
ex.Range(ex.Cells(3, 1), ex.Cells(msh.Rows + 2, msh.cols)).value = printvalue
ex.Range(ex.Cells(1, 1), ex.Cells(msh.Rows + 2, msh.cols)).Borders.LineStyle = 1
ex.Range(ex.Cells(msh.Rows + 3, 1), ex.Cells(msh.Rows + 3, msh.cols)).MergeCells = True
ex.Cells(msh.Rows + 3, 1).Font.Size = 8
ex.Cells(msh.Rows + 3, 1) = companyName
ex.Range(ex.Cells(msh.Rows + 4, 1), ex.Cells(msh.Rows + 4, msh.cols)).MergeCells = True
ex.Cells(msh.Rows + 4, 1).Font.Size = 8
ex.Cells(msh.Rows + 4, 1) = "操作员:" & DatabaseOper.username & " " & gdate.GetDateTime()
exsheet.PageSetup.PrintTitleRows = "$1:$3"
If preview <> 0 Then
ex.Visible = True
exwbook.PrintPreview True
Else
'TEST

exwbook.PrintOut

End If
exwbook.Close False
Set exwbook = Nothing
Set exsheet = Nothing
Set ex = Nothing
Printing = True
Exit Function
printErr:
MsgBox "打印出错,请检查Excel 2000及打印机是否能正常使用!", vbInformation, "提示"
Printing = False
Set exwbook = Nothing
Set exsheet = Nothing
Set ex = Nothing
End Function
  • 打赏
  • 举报
回复
射天狼 2004-04-30
用PICTUREBOX控件模拟吧!!!
  • 打赏
  • 举报
回复
射天狼 2004-04-30
自己写吧,没有!!
  • 打赏
  • 举报
回复
相关推荐
发帖
数据库(包含打印,安装,报表)
加入

1190

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2004-04-30 12:40
社区公告
暂无公告