using DevExpress.XtraEditors; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Gs.DevApp.DevFrm.Rpt { public partial class RptUser : DevExpress.XtraEditors.XtraForm { public RptUser() { InitializeComponent(); DataSet ds = new DataSet(); DataTable table1 = new DataTable(); table1.TableName = "Table1"; // 一定要设置表名称 ds.Tables.Add(table1); // 添加表中的列 table1.Columns.Add("姓名", typeof(string)); table1.Columns.Add("密码", typeof(string)); // 任意添加一些数据 for (int i = 0, maxI = 100; i < maxI; i++) { DataRow row = table1.NewRow(); row["姓名"] = "我是" + i.ToString(); row["密码"] = i.ToString(); table1.Rows.Add(row); } FastReport.Report report = new FastReport.Report(); report.Load("templeEasyCode/Untitled.frx");//bin/debug下 report.RegisterData(ds);//必须装 dataset 数据集,如果装入datatable数据表,要加参数表名,所以加集方便 report.Preview = previewControl1; report.Prepare(); report.ShowPrepared(); } } }