我现在已经把数据取到MSHFlexGrid1中了﹐怎幺样才能以报表的格式把里面的数据打印出来,这是我第一次做报表,有很多东东不懂.如果要做两张报表是不是要有两个DateReprot1呢,不然如何做报表1,报表2,报表3,要如何做呢??

解决方案 »

  1.   

    可以把msflexgrid中的数据导入到excel中:如:Private Sub Toexcel()
        
        Dim xlsApp As excel.Application
        Dim xlsBook As excel.Workbook
        Dim xlsSheet As excel.Worksheet
        Set xlsApp = New excel.Application
        Set xlsBook = xlsApp.Workbooks.Add
        Set xlsSheet = xlsBook.Worksheets(1)
        
        Dim i As Integer
        Dim n As Integer
        For i = 0 To Me.MSFlexGrid1.Rows - 1
            For n = 0 To Me.MSFlexGrid1.Cols - 1
                xlsSheet.Cells(i + 3, n + 1) = Me.MSFlexGrid1.TextMatrix(i, n)
            Next
        Next
        xlsApp.Visible = True
        
    End Sub
      

  2.   

    1.VB自带的报表有好多缺陷,但是基本的功能差不多都可以实现.
    2.先引用DataEnvironment1(数据环境设计器),建一个command1.再建一个报表,把数据源指向    DataEnvironment1,然后直接往报表设计器里拖command1的字段.
    3.如果你报表1,2,3格式不一样最好分开做报表.
    4.要用VB的报表最好先打上VB的SP5补丁
      

  3.   

    报表的格式是一样的,就是不懂要如何做,
    我通过SQL语句查询得到了。所要的记录:
    并显示在MSHFlexGrid1中,
    现在想把所查询得到的记录打出来。如果用DataEnvironment1和command1是不是只能实现command1中所对应的记录的打印功能呢。我是刚开始学习做报表的很多不懂,请问哪边有相关的实例题。
      

  4.   

    VB6中用DataReport做报表 
     
    2002-01-08· ·李文强 ··yesky 
    上一页  1 2  
      最后用一个实例模板来说明其使用方法。  连接数据库With 数据环境.rsCommand名
    If .State = adStateOpen Then .Close
    .Source = SQL语句 
    .Open 打开想输出的数据库数据项以便输出
    End With
    With 报表名
     .DataSource=数据环境
     .DataMember=Command名 这两行也可固定设好而不必每次设置
     设置页表头部分(RpttLabel…为报表控件名)
     .Sections(2).Controls("RptLabelPage").Caption = "共%P页第%p页"
     .Sections(2).Controls("RptLabelDate").Caption = "打印日期:%D"
     .Sections(3).Controls("RptLabel1").Left=…
     …
     设置细节部分(RptShapeX、RptTextBoxX为报表控件名)
     .Sections(3).Controls("RptShape1").Left=…
     .Sections(3).Controls("RptShape1").Top=…
     .Sections(3).Controls("RptShape1").Height=…
     .Sections(3).Controls("RptShape1").Width=…
     .Sections(3).Controls("RptTextBox1").DataMember=Command名
     .Sections(3).Controls("RptTextBox1").DataField=字段1
     .Sections(3).Controls("RptTextBox1").Font.Name=…
     …
     .Sections(3).Controls("RptShapeN").Visible=False
     .Sections(3).Controls("RptTextBoxN").Visible=False
     …
     . Sections(3).Height=计算出的或固定的细节高度
    动态调整报表标题(RptLabelTitle为报表标签控件名)
     .Sections(2). Controls("RptLabelTitle").Left=…
     …
     .Sections(2). Controls("RptLabelTitle").Alignment=…
     …
     调整完毕后
     .Show 或 .PrintReport
    End With
     
     
    我很用这个方法做可是就是学不来哟,老会出现问题
      

  5.   

    http://expert.csdn.net/Expert/topic/2454/2454283.xml?temp=.944668希望这个控件能够帮助你
      

  6.   

    http://expert.csdn.net/Expert/topic/2454/2454283.xml?temp=.944668