?? report.cls
字號:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Report"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
'**************************************************************
'*類模塊名稱:Report
'*類模塊說明:報表類
'*
'*備注:
'*
'*作者:progame
'*日期:2002-03-27 15:09:18
'***************************************************************
Private Const ModalName = "Report"
'*開放對象
Public ColHeader As clsColHeader '*列頭
Public WithEvents Content As clsContent '*正文
Attribute Content.VB_VarHelpID = -1
Public Event InitProgress(Value As Integer) '*初始化的處理進度
Public Event PrintProgress(Value As Integer) '*打印輸出時的處理進度
Public Header As clsCollection '*表頭
Public Footer As clsCollection '*表尾
Public Title As clsCollection '*頁頭
Public Tail As clsCollection '*頁尾
Public LeftSection As clsCollection '*左部標簽集合
Public RightSection As clsCollection '*右部標簽集合
'*打印機的設置
Private m_PrinterWidth As Single
Private m_PrinterHeight As Single
Private m_PrinterOrient As typeOrient
'*頁邊距的設置
Private m_LeftMargin As Single
Private m_RightMargin As Single
Private m_TopMargin As Single
Private m_BottomMargin As Single
'*當前使用的模板文件
Private m_Templatefile As String
'*正文打印的對齊方式
Private m_Align As typeAlign
'*是否有數(shù)據(jù)
Private m_HaveData As Boolean
Public Property Get Align() As typeAlign
'*得到正文打印的對齊方式
Align = m_Align
End Property
Public Property Let Align(vData As typeAlign)
'*設置正文打印的對齊方式
m_Align = vData
End Property
Friend Property Get HaveData() As Boolean
'*是否有數(shù)據(jù)
HaveData = m_HaveData
End Property
'**************************************************************
'*名稱:SetPrinter
'*功能:設置打印機
'*傳入?yún)?shù):
'* width --寬度(如果設為0,則認為讀取系統(tǒng)默認寬度)
'* height --高度(如果設為0,則認為讀取系統(tǒng)默認高度)
'* orient --方向
'*返回參數(shù):
'* 是否設置成功
'*作者:progame
'*日期:2002-03-19 23:10:00
'***************************************************************
Public Function SetPrinter(width As Single, _
height As Single, _
orient As typeOrient) _
As Boolean
'*如果數(shù)值小于0,則為非法
If width < 0 Or height < 0 Then
SetPrinter = False
Exit Function
End If
'*設置
m_PrinterWidth = width
m_PrinterHeight = height
m_PrinterOrient = orient
'*返回成功
SetPrinter = True
End Function
Public Property Get width() As Single
'*得到報表的頁寬度
width = m_PrinterWidth
End Property
Public Property Get height() As Single
'*得到報表的頁高度
height = m_PrinterHeight
End Property
Public Property Get orient() As typeOrient
'*得到報表的打印方向
orient = m_PrinterOrient
End Property
'**************************************************************
'*名稱:SetMargin
'*功能:設置頁邊距
'*傳入?yún)?shù):
'* left --左邊距
'* right --右邊距
'* top --上邊距
'* bottom --下邊距
'*返回參數(shù):
'*
'*作者:progame
'*日期:2002-03-20 15:37:22
'***************************************************************
Public Function SetMargin(Left As Single, _
Top As Single, _
Right As Single, _
Bottom As Single) _
As Boolean
'*過濾非法值
If Left < 0 Or Top < 0 Or Right < 0 Or Bottom < 0 Then
SetMargin = False
Exit Function
End If
If Left + Right >= m_PrinterWidth _
Or Top + Bottom >= m_PrinterHeight Then
SetMargin = False
Exit Function
End If
'*設置
m_LeftMargin = Left
m_RightMargin = Right
m_TopMargin = Top
m_BottomMargin = Bottom
SetMargin = True '*返回成功值
End Function
Public Property Get LeftMargin() As Single
'*得到報表的頁高度
LeftMargin = m_LeftMargin
End Property
Public Property Get RightMargin() As Single
'*得到報表的頁高度
RightMargin = m_RightMargin
End Property
Public Property Get TopMargin() As Single
'*得到報表的頁高度
TopMargin = m_TopMargin
End Property
Public Property Get BottomMargin() As Single
'*得到報表的頁高度
BottomMargin = m_BottomMargin
End Property
'**************************************************************
'*名稱:CalPage
'*功能:計算頁
'*傳入?yún)?shù):
'*
'*作者:progame
'*日期:2002-04-05 14:25:56
'***************************************************************
Public Sub CalPage()
Dim pageheight As Single '*可用頁高
Dim firstPageHeight As Single '*第一頁的可用頁高(減去表頭)
Dim lastPageHeight As Single '*最后一頁的可用頁高(減去表尾)
Dim pagewidth As Single '*可用頁寬
If Not m_HaveData Then
Exit Sub
End If
pagewidth = m_PrinterWidth - (m_LeftMargin + m_RightMargin) _
- LeftSection.GetWidth - RightSection.GetWidth
'*列頭分頁
ColHeader.Merge pagewidth
'*計算正文可用的高度
pageheight = m_PrinterHeight _
- (m_TopMargin + m_BottomMargin) _
- ColHeader.GetHeight _
- Title.GetHeight - Tail.GetHeight
firstPageHeight = pageheight - Header.GetHeight - 1000
lastPageHeight = pageheight - Footer.GetHeight
'*正文分頁
Content.Merge pagewidth, pageheight, firstPageHeight, lastPageHeight
End Sub
Public Property Get pages() As Integer
'*得到總頁數(shù)
pages = Content.GetPages
End Property
Public Property Get cutpages() As Integer
cutpages = ColHeader.cutpages
End Property
'**************************************************************
'*名稱:AttachFlexGrid
'*功能:綁定到FlexGrid
'*傳入?yún)?shù):
'*
'*返回參數(shù):
'*
'*作者:progame
'*日期:2002-04-09 19:59:40
'***************************************************************
Public Function AttachFlexGrid(flexgrid As Object) As Boolean
AttachFlexGrid = funAttachFlexGrid(Me, flexgrid)
m_HaveData = AttachFlexGrid
End Function
'**************************************************************
'*名稱:AttachdataGrid
'*功能:綁定到dataGrid
'*傳入?yún)?shù):
'*
'*返回參數(shù):
'*
'*作者:progame
'*日期:2002-04-09 19:59:40
'***************************************************************
Public Function AttachdataGrid(datagrid As Object) As Boolean
AttachdataGrid = funAttachdataGrid(Me, datagrid)
m_HaveData = AttachdataGrid
End Function
'**************************************************************
'*名稱:Attachmrc
'*功能:綁定到mrc
'*傳入?yún)?shù):
'*
'*返回參數(shù):
'*
'*作者:progame
'*日期:2002-04-09 19:59:40
'***************************************************************
Public Function Attachmrc(mrc As ADODB.Recordset, strheadname() As String, numheadwith() As Integer) As Boolean
Attachmrc = funAttachmrc(Me, mrc, strheadname, numheadwith)
m_HaveData = Attachmrc
End Function
'**************************************************************
'*名稱:AttachListView
'*功能:綁定到listview
'*傳入?yún)?shù):
'*
'*返回參數(shù):
'*
'*作者:progame
'*日期:2002-04-09 19:59:40
'***************************************************************
Public Function AttachListView(listview As Object) As Boolean
AttachListView = funAttachListView(Me, listview)
m_HaveData = AttachListView
End Function
'**************************************************************
'*名稱:Preview
'*功能:預覽
'*傳入?yún)?shù):
'*
'*作者:progame
'*日期:2002-04-05 19:38:22
'***************************************************************
Public Sub Preview()
If Not m_HaveData Then
MsgBox "沒有數(shù)據(jù),無法預覽!", vbInformation + vbOKOnly
Exit Sub
End If
If m_PrinterHeight = 0 Or m_PrinterWidth = 0 Then
MsgBox "沒有可用的打印機或未設定紙張大??!", vbInformation + vbOKOnly
Exit Sub
End If
Dim fPreview As New frmPreview
Set fPreview.rpt = Me
fPreview.Show
Set fPreview = Nothing
End Sub
'**************************************************************
'*名稱:Export2Jpg
'*功能:輸出到jpg文件
'*傳入?yún)?shù):
'* filepath --文件夾位置
'* pageFrom --頁起始
'* cutPageFrom --分頁起始
'* pageTo --頁終止
'* cutPageTo --分頁終止
'* sRate --縮放比例
'* isBmp --輸出BMP還是JPG
'* preFix --輸出文件名的前綴
'*返回參數(shù):
'*
'*作者:progame
'*日期:2002-04-10 11:21:12
'***************************************************************
'**************************************************************
'*名稱:Export2Prn
'*功能:
'*傳入?yún)?shù):
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -