请问MsFlexGrid带打印预览吗?

sonyge 2004-04-30 12:40:44
请问MsFlexGrid带打印预览吗?
...全文
113 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
  • 打赏
  • 举报
回复
自己写吧,没有!!

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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