【机房收费系统】——报表(二)

来源:互联网 发布:淘小白自动发货软件 编辑:程序博客网 时间:2024/06/06 00:32

       上次讲到了报表模板的制作,那么如何将模板与VB连接起来做出报表呢?

       将添加的部件Grid++Report Engine 5.6 Type Library加到窗体,显示如图:

                

以下是具体的代码实现:

Option Explicit    Dim WithEvents report As grproLibCtl.GridppReport    '实例化报表    Private Sub Form_Load()    Dim strsql As String, strmsg As String   '定义字符串        strsql = "select * from checkday_info where date = '" & Format(Date, "yyyy-mm-dd") & "'"  '查询日期    Set report = New grproLibCtl.GridppReport    '实例化模板        report.LoadFromFile (App.Path & "\daycheck.grf")    '加载已经做好的报表模板    report.DetailGrid.Recordset.ConnectionString = Connectstring() '连接数据源    report.DetailGrid.Recordset.QuerySQL = strsql  '通过select查询创建记录集        GRDisplayViewer1.report = report  '将数据赋给grd的report    GRDisplayViewer1.Start  '开始打印        End SubPrivate Sub cmdPrint_Click()    report.[Print] (True)  '打印  ,报表对象的print方法与VB中内部定义有冲突,要加[]End SubPrivate Sub cmdPreview_Click()    report.PrintPreview (True)   '打印预览End SubPrivate Sub cmdUpdate_Click()    GRDisplayViewer1.Refresh    '刷新    MsgBox "刷新成功!"End Sub

               通过对报表的学习了解了很多知识,收获了很多,希望这些能帮到大家。


0 0
原创粉丝点击