name90pp 2019-02-15 22:03 采纳率: 50%
浏览 1245
已采纳

fastreport第二级分组页眉如何实现合计功能

使用fstreport制表时,遇到了需要进行两次分组的情况,导致第二级的页眉内容无法套用demo中的代码实现页数汇总,希望有能人能够指教

报表概览

图片说明

打印预览

图片说明

第二组页码汇总开始错乱

图片说明

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;

namespace FastReport
{
  public class ReportScript
  {
    // The idea is to collect group totals on the first report pass, and to print
    // the collected values on the second pass. 

    // The variable that we going to print in the group header.
    private int totalA;

    // The list that will hold totals for each group.
    private List<int> totals = new List<int>();


    // This handler is called before printing the group header. To create this handler:
    // - select the group header;
    // - go Properties window;
    // - press "Events" button;
    // - select "BeforePrint" event and doubleclick it.
    private void GroupHeader1_BeforePrint(object sender, EventArgs e)
    {
      // Note: ((Int32)Report.GetVariableValue("Row#")) is a current group number;
      // this string is automatically inserted when you drag & drop
      // the "Row#" system variable from the Data Dictionary window to the script.
      // This value is not zero-based.
      int groupNumber = ((Int32)Report.GetVariableValue("Row#"));

      // If this pass is final, get the collected value.
      if (Engine.FinalPass)
        totalA = totals[(groupNumber-1)];
    }

    // This handler is called before printing the group footer.
    private void GroupFooter1_BeforePrint(object sender, EventArgs e)
    {
      // Note: Report.GetTotalValue("TotalProducts") is a total value;
      // this string is automatically inserted when you drag & drop
      // the "TotalProducts" total from the Data Dictionary window to the script.
      int totalValue = (int)Report.GetTotalValue("TotalYS");

      // if this pass is not final, add the total value to the totals list.
      if (!Engine.FinalPass)
        totals.Add(totalValue);
    }
  }
}

  • 写回答

1条回答 默认 最新

  • name90pp 2019-02-15 22:45
    关注

    搞定了,用AbsRow#替换Row#即可

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 主要进行描述泥浆在管路不同区段泥浆的密度不相同,泥浆的密度有高有低,此时管路的摩阻分布需要怎么计算,(标签-matlab)
  • ¥40 通过编制程序计算圆管内层流充分发展对流换热,参数如图5-4,以及公式5-16所示,要求用表5-6对程序计算准确性进行验证
  • ¥20 该学习哪个编程语言? AI会取代程序员吗?
  • ¥15 ensp如何拼通IP地址
  • ¥15 saber软件导入Ibis模型报错
  • ¥15 商城生产日期批次库存问题
  • ¥15 esp8266控制共阳极wrgb灯板无法关闭所有led灯
  • ¥100 python读取速度问题
  • ¥15 stm32f407使用DMA问题
  • ¥15 您好 这个API接口该怎么弄 网站搭建好了 API也有 现在就不知道该怎么填写API 不知道怎么用