你不点击导出,就是一个正常展示可以正常的展示不。由于你用的是动态绑定数据源,打印的时候其实也是需要进行一个动态数据源的绑定的,这是我刚刚写的一个打印这块绑定数据源的一个代码示例- private void button2_Click(object sender, EventArgs e)
- {
- string file_name = @"..\..\RdlReport1.rdlx";
- GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));
- pageReport.Document.LocateDataSource += new LocateDataSourceEventHandler(LocateData);
- pageReport.Document.Printer.DefaultPageSettings.Margins.Bottom = 0;
- pageReport.Document.Printer.DefaultPageSettings.Margins.Left = 0;
- pageReport.Document.Printer.DefaultPageSettings.Margins.Right = 0;
- pageReport.Document.Printer.DefaultPageSettings.Margins.Top = 0;
- pageReport.Document.Printer.PaperSize.RawKind = 0;
- pageReport.Document.Printer.PaperSize.Width = 790;
- //pageReport.Document.Printer.PaperSize.Height = 20;
- GrapeCity.ActiveReports.PrintExtension.Print(pageReport.Document, true, true);//通过设置第二个属性为false实现静默打印。
- }
复制代码- public void LocateData(object sender, LocateDataSourceEventArgs args)
- {
- #region
- if (args.DataSet.Query.DataSourceName == "DataSource1")
- {
- if (args.DataSet.Name == "DataSet1")
- {
- List<FormData> data = new List<FormData>();
- for (int i = 1; i <= 3; i++)
- {
- for (int j = 1; j <= 5; j++)
- {
- for (int k = 1; k <= 2; k++)
- {
- data.Add(new FormData()
- {
- Main = i + "CM主控制器",
- Sub = "T-80" + i + j + "子控制器",
- Variable = "T-80" + i + j + k + ".PV",
- Type = "CV投用情况",
- Active = 0 + (i + j + k) % 2,
- Value = (95 - i / 10.0 + j / 10.0 + k / 100.0) / 100.0
- });
- }
- }
- }
- args.Data = data;
- }
- }
- #endregion
- #region
- if (args.DataSet.Query.DataSourceName == "DataSource2")
- {
- if (args.DataSet.Name == "DataSet2")
- {
- List<TimeInfo> info = new List<TimeInfo>();
- info.Add(new TimeInfo() { Type = "开始时间", Value = Convert.ToDateTime("22/08/2017 09:00:00") });
- info.Add(new TimeInfo() { Type = "结束时间", Value = Convert.ToDateTime("22/08/2017 10:00:00") });
- info.Add(new TimeInfo() { Type = "CV投用指标", Value = 0.95 });
- args.Data = info;
- }
- }
- #endregion
- #region
- if (args.DataSet.Query.DataSourceName == "DataSource3")
- {
- if (args.DataSet.Name == "DataSet3")
- {
- List<Operate> operate = new List<Operate>();
- operate.Add(new Operate() { Number = 1, Type = "SVCTL61", Count = 838 });
- operate.Add(new Operate() { Number = 2, Type = "SVCTL64", Count = 226 });
- operate.Add(new Operate() { Number = 3, Type = "SVCTL23", Count = 222 });
- operate.Add(new Operate() { Number = 4, Type = "SVCTL55", Count = 37 });
- operate.Add(new Operate() { Number = 5, Type = "SVCTL63", Count = 35 });
- operate.Add(new Operate() { Number = 6, Type = "SVCTL01", Count = 30 });
- operate.Add(new Operate() { Number = 7, Type = "SVCTL14", Count = 29 });
- operate.Add(new Operate() { Number = 8, Type = "SVCTL25", Count = 27 });
- operate.Add(new Operate() { Number = 9, Type = "SVCTL02", Count = 26 });
- operate.Add(new Operate() { Number = 10, Type = "SVCTL54", Count = 20 });
- operate.Add(new Operate() { Number = 11, Type = "其他", Count = 969 });
- args.Data = operate;
- }
- }
- #endregion
- }
-
复制代码
|