=IFERROR(REDUCE("",UNIQUE(出货!C2:C218),LAMBDA(m,n,LET(
k,HSTACK("客户:",n," ","联系人:"," "," ","电话: "," ","对帐单号",n),
j,REDUCE({"日期","货 号","名 称","规 格","数量","单价","金额","单号","每单金额","收款金额"},UNIQUE(MONTH(出货!B8:B69)),LAMBDA(x,y,LET(
i,FILTER(HSTACK(出货!B2:B218,出货!D2:D218,出货!E2:K218,出货!O2:O218),(MONTH(出货!B2:B218)=y)*(出货!C2:C218=n),""),
VSTACK(x,i,HSTACK("","","本月合计","",IFERROR(SUM(INDEX(i,,5)),0),"",IFERROR(SUM(INDEX(i,,7)),0)))))),
VSTACK(m,VSTACK(k,j,HSTACK("","","累计","",IFERROR(SUM(INDEX(j,,5))/2,0),"",IFERROR(SUM(INDEX(j,,7))/2,0))))))),"") |