【机房收费系统】——报表(二) 偏执的太偏执、 2022-08-03 00:50 151阅读 0赞 上次讲到了报表模板的制作,那么如何将模板与VB连接起来做出报表呢? 将添加的部件Grid++Report Engine 5.6 Type Library加到窗体,显示如图: ![Center][] 以下是具体的代码实现: 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 Sub Private Sub cmdPrint_Click() report.[Print] (True) '打印 ,报表对象的print方法与VB中内部定义有冲突,要加[] End Sub Private Sub cmdPreview_Click() report.PrintPreview (True) '打印预览 End Sub Private Sub cmdUpdate_Click() GRDisplayViewer1.Refresh '刷新 MsgBox "刷新成功!" End Sub 通过对报表的学习了解了很多知识,收获了很多,希望这些能帮到大家。 [Center]: /images/20220731/08971b708fa04d94b64bb63c3cce3a25.png
还没有评论,来说两句吧...