第一范文网 - 专业文章范例文档资料分享平台

Crystal reports 9 的使用示例

来源:用户分享 时间:2025/10/14 9:04:34 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

Crystal reports 9 的使用示例(一)

'***************************************************************** '*crystal report 的使用示例 '*适用版本:9.0 '*制作人:马亚红

'*制作时间:2004年12月28日

'*情况:此为在水晶报表软件中制作报表(rpt文件)的调用方式 '*菜单->工程->引用->选择:

'*1、Crystal Reports 9 ActiveX Desioner Desion and Runtime Library '*2、Crystal Reports 9 activeX Desioner Run Time Library '*好多朋友有这个问题:报表显示后数据没有刷新,解决方法如下:

'*1、在报表的设计界面,菜单“文件”--》“选项”--》“建立报表”选项卡--》把“将数据与报表一起保存”前的勾去掉后保存即可

'*2、调用报表对象的DiscardSavedData方法

'***************************************************************** Option Explicit

Dim Report As New CrystalReport1

Dim wjfilesys As FileSystemObject 'FSO 对象,用于文件操作 Dim WithEvents CrSecRH As Section '报表显示区对象 Dim capp As New CRAXDDRT.Application '报表集合对象 Dim carp As New CRAXDRT.Report '报表集合中的报表对象 Dim carsubp As New CRAXDRT.Report '报表集合对象中的子报表对象 Dim Pic2 As OLEObject '报表对象中的Ole对象

Dim mytxt As CRAXDRT.TextObject '报表对象中的Textbox对象

Private Sub Combo1_Change() '放大(缩小)比例 CRViewer91.Zoom (CInt(Combo1.Text)) End Sub

Private Sub Command1_Click() '显示第一页 CRViewer91.ShowFirstPage End Sub

Private Sub Command10_Click() '打印报表 CRViewer91.PrintReport End Sub

Private Sub Command11_Click() CRViewer91.showclosebutton End Sub

Private Sub Command2_Click() '刷新报表 CRViewer91.Refresh End Sub

Private Sub Command3_Click() '显示上一页 CRViewer91.ShowPreviousPage End Sub

Private Sub Command4_Click() '显示下一页 CRViewer91.ShowNextPage End Sub

Private Sub Command5_Click() '显示最后一页 CRViewer91.ShowLastPage End Sub

Private Sub Command6_Click() '在报表内容内搜索 If (txtSearch.Text <> \

CRViewer91.SearchForText (txtSearch.Text) End If

txtSearch.Text = \End Sub

Private Sub Command7_Click() '导入出PDF

Dim myExportFile As String

myExportFile = App.Path + \ If wjfilesys.FileExists(myExportFile) Then wjfilesys.DeleteFile (myExportFile) End If

Report.ExportOptions.DiskFileName = myExportFile

Report.ExportOptions.FormatType = crEFTPortableDocFormat Report.ExportOptions.DestinationType = crEDTDiskFile Report.ExportOptions.PDFExportAllPages = True Report.Export (False) End Sub

Private Sub Command8_Click() '导出到Excel Dim myExportFile As String

myExportFile = App.Path + \ If wjfilesys.FileExists(myExportFile) Then wjfilesys.DeleteFile (myExportFile) End If

Report.ExportOptions.DiskFileName = myExportFile Report.ExportOptions.FormatType = crEFTExcel97 Report.ExportOptions.DestinationType = crEDTDiskFile Report.ExportOptions.PDFExportAllPages = True Report.Export (False) End Sub

Private Sub Command9_Click() '导出到WORD Dim myExportFile As String

myExportFile = App.Path + \ If wjfilesys.FileExists(myExportFile) Then wjfilesys.DeleteFile (myExportFile) End If

Report.ExportOptions.DiskFileName = myExportFile

Report.ExportOptions.FormatType = crEFTWordForWindows Report.ExportOptions.DestinationType = crEDTDiskFile Report.ExportOptions.PDFExportAllPages = True Report.Export (False) End Sub

Private Sub Form_Load()

Screen.MousePointer = vbHourglass Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim strsql As String Dim i As Integer

If cn.State = adStateOpen Then cn.Close 'SQL SERVER连接方式 With cn

.Provider = \

.ConnectionString = \.Open End With 'Mdb的连接方式 With cn

.Provider = \

.ConnectionString = \.Open End With

strsql = \

If rs.State = adStateOpen Then rs.Close With rs

.ActiveConnection = cn .CursorLocation = adUseClient

.Open strsql, cn, adOpenDynamic, adLockOptimistic End With

Set carp = capp.OpenReport(App.Path + \'取报表对象 Set carsubp = carp.OpenSubreport(\'取子报表对象

搜索更多关于: Crystal reports 9 的使用示例 的文档
Crystal reports 9 的使用示例.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c3uh9v9rzfi6j6mw9sjhs44p5c1cp2i00dvj_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top