FastReport.net 使用记录

FastReport.net  打印设计功能非常强大,打印内容可以自己设计。数据源可以来至许多个表,打印设计后的表格数据是以二进制保存在数据库中的。

1.打印设计:

  private void DesignReport(object sender, EventArgs e)
        {
           DataSet ds = GetQuery();--数据源,就是你要打印的数据(可以有多个sql语句)
            if (ds == null) return;

            FastReport.Report   r = new FastReport.Report();
            MemoryStream s = LoadStream();--取存在数据库中二进制表格数据
            if (s != null)
                r.Load(s);

            r.RegisterData(ds);
            if (r.Prepare() == true)
            {
                FastReport.Design.StandardDesigner.DesignerForm d = new FastReport.Design.StandardDesigner.DesignerForm();
                d.Designer.cmdSave.CustomAction += new EventHandler(SaveReport);--保存方法
                d.Designer.AskSave = false;
                d.Designer.Report = r;
                d.ShowDialog();
                d.Dispose();
            }
        }

  2.打印预览

public void PreviewReport(object sender, EventArgs e)
        {
            if (gridView1.RowCount == 0) return;

            DataSet ds = GetQuery();
            if (ds == null) return;
        
            MemoryStream s = LoadStream();
            if (s == null) return;

            r = new FastReport.Report();
            r.Load(s);
            r.RegisterData(ds);
            r.Show();
        }

  3.打印

       public void PrintReport(object sender, EventArgs e)
        {
            if (gridView1.RowCount == 0) return;
            DataSet ds = GetQuery();
            if (ds == null) return;
            MemoryStream s = LoadStream();
            if (s == null) return;
            r = new FastReport.Report();
            r.Load(s);
            r.RegisterData(ds);
            r.Print();
            bPrint = true;
        }

  开始我使用这个控件的时候觉得有点复杂,使用了之后其实很简单。就给2个参数:数据源和表单数据。

     文件下载http://files.cnblogs.com/EntityFramework/FRNetDemo2010-NET4.0.zip

原文地址:https://www.cnblogs.com/EntityFramework/p/3345158.html