www.pudn.com > prit.rar > FrmTestPreView.frm.frm
VERSION 5.00
Begin VB.Form Form1
Caption = "胡为平版权所有,huweiping0068@sina.com"
ClientHeight = 3525
ClientLeft = 60
ClientTop = 345
ClientWidth = 5730
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3525
ScaleWidth = 5730
StartUpPosition = 3 '窗口缺省
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "E:\prnprvOcx\CW.mdb"
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 480
Left = 390
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = "rpt"
Top = 720
Width = 3510
End
Begin VB.CommandButton Command3
Caption = "预览数据库"
Height = 420
Left = 3945
TabIndex = 2
Top = 765
Width = 1200
End
Begin VB.CommandButton Command2
Caption = "预览2"
Height = 420
Left = 1665
TabIndex = 1
Top = 2790
Width = 1200
End
Begin VB.CommandButton Command1
Caption = "预览"
Height = 420
Left = 3540
TabIndex = 0
Top = 2760
Width = 1200
End
Begin VB.Label Label2
Caption = "共享版打印的行列数受限制"
Height = 660
Left = 615
TabIndex = 4
Top = 1650
Width = 4200
End
Begin VB.Label Label1
Caption = "请把数据库的路径设置为正确的路径:"
Height = 240
Left = 240
TabIndex = 3
Top = 465
Width = 3840
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Load frmPrnPrv
With frmPrnPrv.HuPrintPreview1
.Redraw = False
.Title = "XXX报表"
.RowsFixedNum = 2
.Cols = 10
.Rows = 22
.SetMerge "A1:A2" '单元合并
.SetMerge "B1:B2"
.SetMerge "C1:D1"
.SetMerge "E1:E2"
.SetMerge "F1:I1"
.ColWidth(0) = 120
.ColWidth(4) = 50
.TextCell(0, 0) = " 项目 月份"
.CellAlign(0, 0) = ALIGN_LEFT_TOP
.TextCell(1, 0) = "A"
.TextCell(2, 0) = "B"
.TextCell(2, 1) = "B1"
.TextCell(3, 1) = "B2"
.TextCell(4, 1) = "B3"
.TextCell(5, 1) = "B4"
.TextCell(4, 0) = "C"
.ColMask(4) = CheckMask
.TextCell(4, 2) = 0
.TextCell(4, 3) = -1
.TextCell(4, 4) = 0
.TextCell(4, 5) = -1
.TextCell(4, 6) = -1
.TextCell(4, 7) = -1
.TextCell(4, 8) = -1
.SetDiagonal 0, 0, 1 '单元格斜线
.SetDiagonal 1, 0, 0 '单元格斜线
.AddGridHead " " '空一行
.AddGridHead "编制单位:A单位 2005年12月12日"
.AddGridHead " " '空一行
.PageNumType = 2 ' '0:无 1: 第几页共几页 2: 第几页 3: n . N 4: .n. 小于0表示首面无页码
.AddGridFoot "胡为平版权所有,huweiping0068@sina.com" ' 设置表格之后显示的文本
.Redraw = True
End With
frmPrnPrv.Show
End Sub
Private Sub Command2_Click()
Load frmPrnPrv
With frmPrnPrv.HuPrintPreview1
.Redraw = False
.Title = "XXX报表"
.RowsFixedNum = 2
.Rows = 32
.Cols = 10
.SetMerge "A1:A2"
.SetMerge "B1:B2"
.SetMerge "C1:D1"
.SetMerge "E1:E2"
.SetMerge "F1:I1"
.ColWidth(0) = 120
.ColWidth(4) = 50
.TextCell(0, 0) = "项目"
.TextCell(1, 0) = "A"
.TextCell(2, 0) = "B"
.TextCell(2, 1) = "B1"
.TextCell(3, 1) = "B2"
.TextCell(4, 0) = "C"
.TextCell(0, 2) = "12"
.TextCell(0, 3) = "13"
.TextCell(0, 4) = "14"
.TextCell(1, 2) = "112"
.TextCell(1, 3) = "113"
.TextCell(1, 4) = "114"
'.GridType = NoHorizontalLine2 '表格线类型
.GridType = NoHorizontalLine '表格线类型
' .GridType = FixedRowLine_Thick
' .GridType = AllLine_Thick
'.GridType = AllLine_Thin
.AddGridHead " " '空一行
.AddGridHead "编制单位:A单位 2005年12月12日"
.AddGridHead " " '空一行
.AddGridFoot " " '空一行
.AddGridFoot "制表人:张三"
.AddGridFoot "胡为平版权所有,huweiping0068@sina.com" ' 设置表格之后显示的文本
.Redraw = True
End With
frmPrnPrv.Show
End Sub
Private Sub Command3_Click()
Load frmPrnPrv
With frmPrnPrv.HuPrintPreview1
.Redraw = False '禁止刷新
.Title = "XXX报表" '标题
' .TitleLine = False '标题下不划线
'.RowsFixedNum = 2 '设置固定行数,数据库记录不显示在固定行
Set .Recordset = Data1.Recordset
.GridType = FixedRowLine_Thick '设置表格线的类型
' .GridType = AllLine_Thick
'.GridType = AllLine_Thin
.DefaultColWidth = 70 '默认列宽
.ColWidth(0) = 110 '列宽
.ColWidth(1) = 20
' .ColWidth(2) = 70 '=默认列宽
' .ColWidth(3) = 70
.ColWidth(4) = 110
.ColWidth(5) = 20
'.ColWidth(6) = 70
'.ColWidth(7) = 70
.RowHeight(0) = 30 '行高
.DefaultRowHeight = 20 '默认行高
.ColAlign(1) = ALIGN_CENTER_VCENTER '列对齐
.ColDecimal(2) = 2 '列小数位,两位小数
.ColBeCurrency = 6 '列货币格式,两位小数,加分节号
.ColBeCurrency = 7
.TextCell(5, 0) = "行次" '设置单元格值
.TextCell(6, 0) = "期初数"
'.TextCell(7, 0) = "期末数"
' .SetDiagonal 0, 0, 1 '单元格斜线
' .SetDiagonal 0, 0, 0 '单元格斜线
.AddGridHead " " '空一行 设置表格之前显示的文本
.AddGridHead "编制单位:A单位 2005年12月12日"
.AddGridHead " " '空一行
.AddGridFoot " " '空一行
.AddGridFoot "制表人:张三" ' 设置表格之后显示的文本
.AddGridFoot "胡为平版权所有,huweiping0068@sina.com" ' 设置表格之后显示的文本
'.PageNumType = 2 ' '0:无 1: 第几页共几页 2: 第几页 3: n . N 4: .n. 小于0表示首面无页码
.LRWidth = 567 * 2.5 / Screen.TwipsPerPixelX ' 2.5cm 左右边距
.UDHeight = 567 * 1.5 / Screen.TwipsPerPixelX ' 1.5cm 上下边距
.CombineMargin = 0 ' 567 * 0.8 / Screen.TwipsPerPixelX ' 0.8cm 装订边距
.Redraw = True '刷新
End With
frmPrnPrv.Show
End Sub
Private Sub Form_Load()
' Data1.DatabaseName = App.Path & "\cw.mdb"
End Sub