我有一个疑惑:
当我设计水晶报表时,我需要确定页面的设置(如横向,纵向,A3或A4)
这些设置在哪里做呢? 当我打印水晶报表时,我需要确定打印机的设置,(如缺省打印机或其他打印机)
并且能调整原来的页面的设置,这些设置在哪里做呢? 希望大侠们能给出具体的solution
当我设计水晶报表时,我需要确定页面的设置(如横向,纵向,A3或A4)
这些设置在哪里做呢? 当我打印水晶报表时,我需要确定打印机的设置,(如缺省打印机或其他打印机)
并且能调整原来的页面的设置,这些设置在哪里做呢? 希望大侠们能给出具体的solution
1 用Crystal Report 8.0设计好报表
2 在VB中,project/add crystal report 8
3 会自动创建两个文件,一个含有crytal viewer空间的form(form2),和一个crystalreport1.dsr(可以更名的)。
4 然后可以写代码控制了。例如:
在Form2上
Public Sub SetRs(vData As Object)
Set mvarRs = vData
End SubPublic Sub SetCaption(ByVal sCaption As String)
mvarCaption = sCaption
End Sub
Public Sub SetViewAppearance(Optional ByVal EnableGroupTree As Boolean = False, Optional ByVal EnableExportButton As Boolean = False, Optional ByVal EnablePopupMenu As Boolean = False, Optional ByVal EnableRefreshButton As Boolean = False, Optional ByVal EnableProgressControl As Boolean = False)
mvarGroupTreeEnabled = EnableGroupTree
mvarExportButtonEnabled = EnableExportButton
mvarPopupMenuEnabled = EnablePopupMenu
mvarRefreshButtonEnabled = EnableRefreshButton
mvarProgressBarEnabled = EnableProgressControl
End Sub
Public Sub SetGroupTreeEnabled(Optional ByVal bGroupTreeEnabled As Boolean = False)
mvarGroupTreeEnabled = bGroupTreeEnabled
End Sub
Public Sub SetExportButtonEnabled(Optional ByVal bExportButtonEnabled As Boolean = False)
mvarExportButtonEnabled = bExportButtonEnabled
End SubPublic Sub SetPopupMenuEnabled(Optional ByVal bPopupMenuEnabled As Boolean = False)
mvarPopupMenuEnabled = bPopupMenuEnabled
End SubPublic Sub SetProgressBarEnabled(Optional ByVal bProgressBarEnabled As Boolean = False)
mvarProgressBarEnabled = bProgressBarEnabled
End SubPublic Sub SetRefreshEnabled(Optional ByVal bRefreshButtonEnabled As Boolean = False)
mvarRefreshButtonEnabled = bRefreshButtonEnabled
End Sub
Public Sub SetReportObject(oCrxReport As Object)
Set crxReport = oCrxReport
End SubPublic Sub SetQuerySQL(ByVal sSQL As String)
mvarSQL = sSQL
End Sub
Public Sub SetParams(ByRef oParams As Parameters)
Set mvarParams = oParams
End Sub'Public Sub SetQueryType(ByVal RptType As ReportSQLType)
' mvarRptType = RptType
'End SubPrivate Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)
crxReport.PrinterSetup (Me.hWnd)
End SubPrivate Sub Form_Load()
On Error GoTo err1
Screen.MousePointer = vbHourglass
Dim oParam As Parameter
Dim i As Integer
Me.Caption = mvarCaption
' Set crxApp = New CRAXDRT.Application
'
' RptConnectDB crxReport
'
' Set crxParameterFields = crxReport.ParameterFields
'
' For Each oParam In mvarParams
' For Each crxParameterField In crxParameterFields
' If crxParameterField.ParameterFieldName = oParam.ParamName Then
' crxParameterField.ClearCurrentValueAndRange
' crxParameterField.AddCurrentValue oParam.Value
' End If
' Next crxParameterField
' Next oParam
' Select Case mvarRptType
' Case ReportSQLType.vbCrystalView
' crxReport.SQLQueryString = mvarSQL
' Case ReportSQLType.vbCrystalADO
Set crxReport = New CrystalReport1
crxReport.Database.SetDataSource mvarRs
' End Select
CRViewer1.Visible = True
CRViewer1.ReportSource = crxReport
With CRViewer1
.EnableGroupTree = mvarGroupTreeEnabled
.EnableExportButton = mvarExportButtonEnabled
.EnablePopupMenu = mvarPopupMenuEnabled
.EnableProgressControl = mvarProgressBarEnabled
.EnableRefreshButton = mvarRefreshButtonEnabled
End With
Screen.MousePointer = vbDefault
CRViewer1.ViewReport
Exit Sub
err1:
Screen.MousePointer = vbDefault
MsgBox Err.Description, vbExclamationEnd SubPrivate Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidthEnd Sub其中,在CRViewer1_PrintButtonClicked(UseDefault As Boolean)里写上
crxReport.PrinterSetup (Me.hWnd) 可以让你的用户自由选择打印机
有几个地方可以设置page 和 printer.
1. Crystal Report Design Stage ( 通过print setup)
2. VB Form (通过coding)
3. Runtime OS Print Setup 我认为,关于页面,在1处的设置是最终的设置,是不会被2,3 overwrited .
关于打印机,在3处的设置是最终的设置