一、设报表的DoublePass为true, 如图
二、编写FastReport的脚本
//定義相關變量
Dictionary<string, int> dic = new Dictionary<string, int>();
int curPage, totalPages;
string oldNo = "";
string curNo = "";
private void PageHeader1_BeforePrint(object sender, EventArgs e)
{
curNo = ((String)Report.GetColumnValue("MasterSelected.客戶代碼"));
//首次,为每客户累计页码
if (Engine.FirstPass)
{
if (dic.ContainsKey(curNo))
{
dic[curNo] = dic[curNo] + 1;
}
else
{
dic[curNo] = 1;
}
}
//第2次,取客户累计页码
if (Engine.FinalPass)
{
//當前頁(單客戶)
if (oldNo != curNo)
{
curPage = 1; //重置客户页码
oldNo = curNo;
}
else
{
curPage = curPage + 1; //客户页码+1
}
//總頁數(單客戶)
totalPages = dic[curNo];
}
}
三、介面引用定义的变量,如图: