如果除了查询名次之外,还需要知道姓名、成绩,只需要小的改动即可(注意单元格设置成自动换行)。
- =LET(sType,SCAN("",录入表!A3:A28,LAMBDA(x,y,IF(y="",x,y))),sn,SCAN("",录入表!C2:T2,LAMBDA(x,y,IF(y="",x,y))),stitle,REDUCE("",录入表!C2:T2,LAMBDA(x,y,HSTACK(x,REPTARRAY(y,26)))),sRow,DROP(REDUCE("",SEQUENCE(,6,1,3),LAMBDA(x,y,VSTACK(x,HSTACK(sType,录入表!B3:B28,CHOOSECOLS(stitle,y+1),OFFSET(录入表!B2,1,y,26,3))))),1),sClass,SCAN("",A3:A22,LAMBDA(x,y,IF(y="",x,y))),Res,REDUCE("",C2:P2,LAMBDA(XX,YY,HSTACK(XX,MAP(SEQUENCE(20),LAMBDA(y,XLOOKUP(YY&INDEX(sClass,y)&INDEX(B3:B22,y),BYROW(CHOOSECOLS(sRow,{1,4,2}),CONCAT),BYROW(CHOOSECOLS(sRow,{3,5,6}),LAMBDA(x,TEXTJOIN(CHAR(10),,x))),"",0)))))),DROP(Res,,1))
复制代码 |