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

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 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办