grape_puppet 发表于 2016-4-21 17:12:14

怎么同时打印两张不同的报表?

本帖最后由 Lenka.Guo 于 2016-4-27 13:39 编辑

两张分开单张打印时,没有问题;同时打印直接重叠在一起了,怎么处理?

grape_puppet 发表于 2016-4-21 17:12:58

private void GenerateReport()
    {
      billtype = Request.QueryString["BillType"];
      billcode = Request.QueryString["BillCode"];

      string[] codelength = billcode.Split(',');

      report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("reportRdlx//Temp3.rdlx")));// 1/2

      // 创建 Container 控件,用户加载 Subreport 控件
      GrapeCity.ActiveReports.PageReportModel.Container container = new GrapeCity.ActiveReports.PageReportModel.Container();
      container.Name = string.Format("Container{0}", 1);
      container.Width = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("1cm");
      container.Height = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("1cm");
      container.Left = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("0cm");
      container.Top = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length((1 * (1 - 1)).ToString() + "cm");
      container.PageBreakAtEnd = true;
      container.PageBreakAtStart = false;
      #region 收
      // 创建 Subreport 控件,用户加载实际报表模板 -- 收料单
      GrapeCity.ActiveReports.PageReportModel.Subreport subreport = new GrapeCity.ActiveReports.PageReportModel.Subreport();
      subreport.Name = string.Format("SubReport{0}", 1);
      subreport.Width = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("1cm");
      subreport.Height = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("1cm");
      subreport.Left = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("0cm");
      subreport.Top = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("0cm");
      GrapeCity.ActiveReports.PageReportModel.Parameter pid = new GrapeCity.ActiveReports.PageReportModel.Parameter();
      pid.Name = "billcode";
      pid.Value = codelength.ToString();
      subreport.Parameters.Add(pid);

      //收料单
      subreport.ReportName = "IBMTFormNew.rdlx";
      container.ReportItems.Add(subreport);
      #endregion

      #region 发
      // 创建 Subreport 控件,用户加载实际报表模板    -- 发料单
      GrapeCity.ActiveReports.PageReportModel.Subreport subreport2 = new GrapeCity.ActiveReports.PageReportModel.Subreport();
      subreport2.Name = string.Format("SubReport{0}", 2);
      subreport2.Width = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("1cm");
      subreport2.Height = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("1cm");
      subreport2.Left = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("0cm");
      subreport2.Top = new GrapeCity.ActiveReports.Extensibility.Definition.Components.Length("0cm");
      GrapeCity.ActiveReports.PageReportModel.Parameter pid2 = new GrapeCity.ActiveReports.PageReportModel.Parameter();
      pid2.Name = "billcode";
      pid2.Value = codelength.ToString();
      subreport2.Parameters.Add(pid2);

      //发料单
      subreport2.ReportName = "RGiveMatl.rdlx";
      container.ReportItems.Add(subreport2);
      #endregion
      report.Report.Body.ReportItems.Add(container);

      report.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(pageDocument_LocateDataSource);
    }

grape_puppet 发表于 2016-4-21 17:13:49

用的rdl报表。

grape_puppet 发表于 2016-4-21 17:50:31

问题已解决。

Lenka.Guo 发表于 2016-4-21 17:54:21

grape_puppet 发表于 2016-4-21 17:13
用的rdl报表。

代码写的真好~:hjyzw:

我理解您的需求是:在同一个Viewer 中通过SubReport 来加载”收料单“和”发料单“两张报表吗?

重叠可能是SubReport 未设置Location 属性而导致的,建议您为SubReport 添加Loacation属性。



页: [1]
查看完整版本: 怎么同时打印两张不同的报表?