|
做了一个总表模板,方便复制,楼主的办公软件是WPS,JSA代码可用
- function 表格拆分(){
- let arr=Sheets.Item("总表").Range("a1").CurrentRegion.Value2;
- let obj=arr.slice(3).reduce((dic,x)=>((dic[x[7]]=dic[x[7]] || []).push(x),dic),{});
- Application.DisplayAlerts=false;
- for (let key in obj){
- let temp=obj[key];
- try{Sheets.Item(key).Delete()}catch{};
- Sheets.Item("总表模板").Copy(null,Sheets.Item(Sheets.Count));
- ActiveSheet.Name=key;
- if (temp.length>2) Range("a5").Resize(temp.length-2,1).EntireRow.Insert();
- Range("a4").Resize(temp.length,temp[0].length).Value2=temp;
- }
- Application.DisplayAlerts=true;
- alert("拆分完毕。");
- }
复制代码 |
|