private void button2_Click(object sender, EventArgs e) { FastReport.Report report1 = new FastReport.Report(); try { // load the existing report // report1.Load("E:\\FsFile\\Untitled.frx"); report1.Load("E:\\FsFile\\Test.frx"); /* * //填充参数及对应的值 * Type typePrint = typeof(LableTag); * System.Reflection.PropertyInfo[] pros = typePrint.GetProperties(); * foreach (System.Reflection.PropertyInfo pro in pros) * { * object val = pro == null ? "" * : pro.GetValue(lableTags[0], null) == null ? "" * : pro.GetValue(lableTags[0], null).ToString(); * * if (val == null) * { * val = ""; * } * string paraName = "lableTag." + pro.Name; * report1.SetParameterValue(paraName, val); * * } * var lableTag = new LableTag(); * lableTag.ProdNo = "800-sdashd-a0-0"; * lableTag.Qty = "300"; * lableTags = new LableTag[] { lableTag }; * * report1.RegisterData(lableTags, "lableTag"); */ report1.SetParameterValue("aaa", "111"); report1.SetParameterValue("bbb", "222"); report1.SetParameterValue("ccc", "333"); report1.Design(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // free resources used by report report1.Dispose(); } }
//public static void BuildReportParmsAndData(FastReport.Report report, ReportArgs reportArgs) //{ // report.Parameters.Clear(); // List<FastReport.Data.Parameter> lstParm = new List<FastReport.Data.Parameter>(); // if (reportArgs.RecordDR != null) // { // foreach (DataColumn dc in reportArgs.RecordDR.Table.Columns) // { // FastReport.Data.Parameter parm = new FastReport.Data.Parameter(dc.ColumnName); // parm.DataType = dc.DataType; // parm.Value = reportArgs.RecordDR[dc.ColumnName]; // lstParm.Add(parm); // } // } // if (reportArgs.DSDataSource != null) // { // foreach (DataTable dtSource in reportArgs.DSDataSource.Tables) // { // report.RegisterData(dtSource, dtSource.TableName); // report.GetDataSource(dtSource.TableName).Enabled = true; // } // } //} /// <summary> /// 打开报表设计器 /// </summary> /// <param name="lReportTemplateID"></param> /// <param name="reportArgs"></param> public static void OpenReportDesign(ReportRequestArgs reportArgs) { string strReportFileName; bool bolExists = RefleshClientReport(reportArgs.ReportTemplateID, out strReportFileName); if (bolExists) { using (FastReport.Report report = new FastReport.Report()) { BuildParmsAndData(reportArgs, report, enBuildParmsAndDataActionType.AddNew); report.Load(strReportFileName); Form frm = new Form(); frm.Icon = FastReport.Utils.Config.PreviewSettings.Icon; frm.Show(); report.Design(); report.Dispose(); frm.Close(); } } }
public void Design() { rpt.Design(); }