Winform开发中使用FastReport基本操作创建与设计



C#程序中用到FastReport报表,把程序界面的数据打印出来。

一、项目导入FastReport.net控件 [引用] -- [添加引用]

二、FastReport.dllFastReport.Bars.dllFastReport.Web.dll添加到工具箱


三、创建项目,并在界面添加report控件


四、双击report1,打开设计报表并保存(添加设计的textSubreport1)注意Subreport1是在另一个分页设计的,用来显示数据。

现在还没有数据源,frxdata1是自己定的数据集别名,到时需要在程序代码中注册。[frxdata1.BILLNO]是对应的数据列。

保存报表文件为***.frx

五、程序调用报表

   privatevoid button1_Click(object sender, EventArgs e)

       {

           string filename =@"D:\CODE\Projects\WForm_Report\Report\test.frx";

           Report report =newReport();

           report.Load(filename);

           //这里是为报告注册数据第二个参数表示此数据在报告中的别名,就是和模版中的[frxdata1.CName] frxdata1对应的名称

           //例如:[frxdata1.billNo]

           report.RegisterData(dataSet1.Tables[0],"frxdata1");

           //找到 Databind绑定数据一定要先注册数据才可以邦定 

           DataBand data = report.FindObject("Data1")asDataBand;

           data.DataSource =report.GetDataSource("frxdata1");

           report.GetDataSource("frxdata1").Enabled =true;

           report.Prepare();

           //显示 

           report.Show();

           //释放资源 

           report.Dispose();

       }

六、设计按钮,可以让用户自定义设计报表

           string filename =@"D:\CODE\Projects\WForm_Report\Report\test.frx";

           Report report =newReport();

           report.Load(filename);

           report.Design();

           //释放资源 

           report.Dispose();


  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值