www.pudn.com > prit.rar > FrmTestPreView.frm
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1
Caption = "胡为平版权所有,huweiping0068@sina.com"
ClientHeight = 3150
ClientLeft = 60
ClientTop = 345
ClientWidth = 7710
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3150
ScaleWidth = 7710
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc1
Height = 405
Left = 420
Top = 1290
Width = 2190
_ExtentX = 3863
_ExtentY = 714
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\prnprvOcx\CW.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\prnprvOcx\CW.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "余额"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command4
Caption = "预览数据库ADO"
Height = 420
Left = 2670
TabIndex = 5
Top = 1305
Width = 1605
End
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 = 2235
End
Begin VB.CommandButton Command3
Caption = "预览数据库DAO"
Height = 420
Left = 2670
TabIndex = 2
Top = 735
Width = 1545
End
Begin VB.CommandButton Command2
Caption = "预览2"
Height = 420
Left = 2760
TabIndex = 1
Top = 1830
Width = 1200
End
Begin VB.CommandButton Command1
Caption = "预览"
Height = 420
Left = 1020
TabIndex = 0
Top = 1860
Width = 1200
End
Begin VB.Label Label3
Caption = $"FrmTestPreView.frx":0000
Height = 2385
Left = 4590
TabIndex = 6
Top = 240
Width = 2865
End
Begin VB.Label Label2
Caption = "共享版打印的行列数受限制"
Height = 315
Left = 1050
TabIndex = 4
Top = 2670
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
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\prnprvOcx\CW.mdb;Persist Security Info=False
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 Command4_Click()
Load frmPrnPrv
With frmPrnPrv.HuPrintPreview1
.Redraw = False '禁止刷新
.Title = "XXX报表" '标题
' .TitleLine = False '标题下不划线
Adodc1.Refresh '不能缺少
Set .Recordset = Adodc1.Recordset
.GridType = FixedRowLine_Thick '设置表格线的类型
' .GridType = AllLine_Thick
'.GridType = AllLine_Thin
.DefaultColWidth = 70 '默认列宽
' .ColWidth(0) = 110 '列宽
.RowHeight(0) = 30 '行高
.DefaultRowHeight = 20 '默认行高
.ColNameFontBold = False '表头粗体=false
.ColDecimal(5) = 2 '列小数位,两位小数,不加分节号
.ColBeCurrency = 3 '第4列为货币格式,两位小数,加分节号
' .ColAlign(1) = ALIGN_CENTER_VCENTER '列对齐
.ColDecimal(2) = 2 '列小数位,两位小数
' .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"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CW.mdb;Persist Security Info=False "
End Sub