| | | | 上一页 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
| 这样做的优点是报表设计时简单,调整方便、随意,只需更改一点代码,而不必为了一点点的修改而费神的在设计窗口调整半天。
上一页 1 2
【责任编辑:方舟】
| |