|
JSA代码,供参考
- function 整理数据(){
- const arr=Sheets.Item("柱 ").Range("a1").CurrentRegion.Value2;
- const shname=Sheets.Item("柱 ").Name,wbname=ThisWorkbook.Name.replace(/.xls[xm]?$/,"");
- const regex1=/^.+(?=\()/, regex2=/(?<=\().+(?=\))/;
- let res=arr.slice(1).reduce((res,x)=>{
- let [xm,lc]=[regex1,regex2].map(re=>re.test(x[0])?x[0].match(re)[0]:null);
- [x[0], x[x.length], x[x.length]]=[lc || x[0], shname, xm || wbname];
- return (res.push(x),res);
- },[arr[0].concat(["构建类型","项目名称"])]);
- Sheets.Item("整理后").Activate();
- Cells.Clear();
- Range("a1").Resize(res.length,res[0].length).Value2=res;
- Range("a1").CurrentRegion.Borders.LineStyle=1;
- Range("a1").CurrentRegion.EntireColumn.AutoFit();
- }
复制代码 |
|