使用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);
}
}
}