FastReport打印table

经过验证是对的。

table第一行添加标题,也就是拖过来的文本label,第二行开始绑定数据源的字段。

先设计报表的静态部分,再用代码注册数据源,然后设计,添加注册的数据源,绑定字段。

1            
2             var report = new Report();
3             report.Load(ProTaskReport);
4             report.RegisterData(new [] {header}, "header");
5             report.RegisterData(body, "body");
6             report.RegisterData(sum, "sum");
7             //report.Design();
8             report.Print();

在报表内添加table的print行。

 1 private void Table2_ManualBuild(object sender, EventArgs e)
 2     {
 3       DataSourceBase body = Report.GetDataSource("sum");
 4       body.Init();
 5       Table2.PrintRow(0);
 6       Table2.PrintColumns();                       
 7       while(body.HasMoreRows){
 8         Table2.PrintRow(1);
 9         Table2.PrintColumns();
10         body.Next();  
11       }
12     }

 2017-5-17 补充

其实这样做没必要,可以将数据部分写在data body里面,绑定数据源字段即可。

 

posted on 2017-05-12 12:11  jonney_wang  阅读(2384)  评论(0编辑  收藏  举报

导航