FastReport.net 使用記錄

FastReport.net  打印設計功能很是強大,打印內容能夠本身設計。數據源能夠來至許多個表,打印設計後的表格數據是以二進制保存在數據庫中的。sql

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.打印預覽.net

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個參數:數據源和表單數據。orm

     文件下載http://files.cnblogs.com/EntityFramework/FRNetDemo2010-NET4.0.zipblog

相關文章
相關標籤/搜索