Data report控件一共有5个区组成,分别是报表头、页面头、细节区、页面注脚和报表注脚。报表头和报表注脚是用分别用于整个报表的最上部和最下部,它们将出现于整个报表的每一页,可以放置一些报表名称,时间之类的固定文本;页面头和页面注脚只能出现在当前页的最上部和最下部,也就是说它只能出现在当前页中,不出现在其他页面中,可以放置随页面变化的一些量比如页码等;而细节区就是用来进行实际显示的区域,它是我们最为关心的区域,通过在此区域内放置显示控件可以控制报表的实际显示输出。这里介绍一下放置文本框控件的使用方法,其实在绑定情况下只需要设置其DataMember和Datafield即可,前者用来指定数据表,可以设置为前面数据环境对象的Command对象,后者是指定数据段,即绑定的数据库的指定字段。这样不需要编写任何代码就可以实现报表的显示工作。
Function OpenBook(strFilePath As String) As Boolean ' This procedure checks to see if the workbook ' specified in the strFilePath argument is open. ' If it is open, the workbook is activated. If it is ' not open, the procedure opens it. Dim wkbCurrent As Excel.Workbook Dim strBookName As String
On Error GoTo OpenBook_Err ' Determine the name portion of the strFilePath argument. strBookName = NameFromPath(strFilePath) If Len(strBookName) = 0 Then Exit Function If Workbooks.Count >0 Then For Each wkbCurrent In Workbooks If UCase$(wkbCurrent.Name) = UCase$(strBookName) Then wkbCurrent.Activate Exit Function End If Next wkbCurrent End If Workbooks.Open strBookName OpenBook = True OpenBook_End: Exit Function OpenBook_Err: OpenBook = False Resume OpenBook_End End Function
推荐文章: