![]() |
新闻 | 体育 | 财经 | 娱乐 | 商业 | 科技 | 汽车 | 数码 | 女人 | 旅游 | 教育 | 文化 | 广州 | 军事 | 部落 评论 | NBA | 明星 | 证券 | 基金 | 探索 | 房产 | 手机 | 两性 | 健康 | 培训 | 电影 | 游戏 | 拍卖 | 论坛 |
| 科技首页 | 重磅报道 | 专题 | IT茶馆 | 技术趋势 | 科学 | 学院 | 游戏 | 病毒 | 下载 | 论坛 | ![]() |
我不是VB熟练工,最近刚刚用VB做完一个程序,其中控制部分没费太大周折,倒是报表部分颇让我费了一翻脑筋。在网上找了半天,也没找到关于VB6的 DataReport的详细介绍,于是想借鉴"前辈"们的经验,用CrystalReport或EXCEL,感觉也不省劲,于是决定回头再去"啃"DataReport,别说,还真让有所收获,下面就简单的介绍一下我的体会,希望对大家能有所帮助。
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

[编辑:邹妙君] [返回首页]
推荐文章: