在映射表中,我有一Exceptions
列,其中一些单元格包含具有多个自定义分隔符的字符串,即,
Client1~Analyst1*Client2~Analyst2 etc
映射表:
+---------------+------------------+----------------------------------------------------+
| Project Owner | Assigned Analyst | Exceptions |
+---------------+------------------+----------------------------------------------------+
| Nico Vera | Maple | Globus Ltd~Walter Lobo*Kevin Kline~Sarah Wick*Monsanto Ltd~Ana Wier |
+---------------+------------------+----------------------------------------------------+
| Vijay Malya | Sonny | |
+---------------+------------------+----------------------------------------------------+
| Sam Tucker | Parvati | Mars~Sonapuri*China Blue~Mona Dsa |
+---------------+------------------+----------------------------------------------------+
| Pessy Shroff | Roy | Harbinger Ltd~Jose Silva*Theos Ltd~Jay Mills |
+---------------+------------------+----------------------------------------------------+
从另一个FC Table
如下图:
FC表:
+------+---------------+---------------+
| ID | Project Owner | Client |
+------+---------------+---------------+
| 1001 | Nico Vera | Globus Ltd |
+------+---------------+---------------+
| 1002 | Vijay Malya | Ventura |
+------+---------------+---------------+
| 1003 | Vijay Malya | Ventura |
+------+---------------+---------------+
| 1004 | Sam Tucker | Mocha Coffee |
+------+---------------+---------------+
| 1005 | Nico Vera | Roma Fashions |
+------+---------------+---------------+
| 1012 | Nico Vera | Monsanto Ltd |
+------+---------------+---------------+
| 1006 | Pessy Shroff | Murdoch Ltd |
+------+---------------+---------------+
| 1007 | Pessy Shroff | Harbinger Ltd |
+------+---------------+---------------+
| 1008 | Pessy Shroff | Theos Ltd |
+------+---------------+---------------+
| 1009 | Sam Tucker | Mars |
+------+---------------+---------------+
| 1013 | Sam Tucker | China Blue |
+------+---------------+---------------+
| 1010 | Nico Vera | Kevin Kline |
+------+---------------+---------------+
| 1014 | Nico Vera | Galettos |
+------+---------------+---------------+
每次,我都想将这些唯一的项目行拉到另一个名为Study Report
table 的历史表中,并且对于这些行中的每一行,检查表列中的Project Owner
任何异常。如果给出任何例外,那么对于任何组合,我想添加客户的相应分析师,否则添加映射表中给出的默认分析师。Exceptions
Mappings
Client-Analyst
Assigned Analysts
研究报告表:
+------+---------------+---------------+------------------+
| ID | Project Owner | Client | Assigned Analyst |
+------+---------------+---------------+------------------+
| 1001 | Nico Vera | Globus Ltd | Walter Lobo |
+------+---------------+---------------+------------------+
| 1002 | Vijay Malya | Ventura | Sonny |
+------+---------------+---------------+------------------+
| 1003 | Vijay Malya | Fountain Pens | Sonny |
+------+---------------+---------------+------------------+
| 1004 | Sam Tucker | Mocha Coffee | Parvati |
+------+---------------+---------------+------------------+
| 1005 | Nico Vera | Roma Fashions | Maple |
+------+---------------+---------------+------------------+
| 1012 | Nico Vera | Monsanto Ltd | Ana Wier |
+------+---------------+---------------+------------------+
| 1006 | Pessy Shroff | Murdoch Ltd | Roy |
+------+---------------+---------------+------------------+
| 1007 | Pessy Shroff | Harbinger Ltd | Jose Silva |
+------+---------------+---------------+------------------+
| 1008 | Pessy Shroff | Theos Ltd | Jay Mills |
+------+---------------+---------------+------------------+
| 1009 | Sam Tucker | Mars | Sonapuri |
+------+---------------+---------------+------------------+
| 1013 | Sam Tucker | China Blue | Mona Dsa |
+------+---------------+---------------+------------------+
| 1010 | Nico Vera | Kevin Kline | Sarah Wick |
+------+---------------+---------------+------------------+
| 1014 | Nico Vera | Galettos | Maple |
+------+---------------+---------------+------------------+
有谁知道如何拆分 Exceptions 列并使用 Typescript for Excel 执行此操作?非常感激任何的帮助。
编辑:
....
// pick Opportunity Owner, FC Name, CD Team & Exceptions from Mapping sheet
let mapObj = MapTable.getRangeBetweenHeaderAndTotal().getValues()
.reduce((o, [a, b, c, d]) => Object.assign(o, { [a as string]: [b, c, d] }), {});
let existingIdsObj = StudyTable.getColumnByName("Study Number").getRangeBetweenHeaderAndTotal().getValues().reduce((o, [a]) => Object.assign(o, { [a as string]: true }), {});
let putValues:string[][] = FCTable.getRangeBetweenHeaderAndTotal().getValues().reduce((ar:string[][], [a, b, c, d, e, f, g, h, i, j, k, l,m]) => {
if (!existingIdsObj.hasOwnProperty(a as string)) {
// this is where i need help to define a loop for x
let x: string = (mapObj[d as string][2].trim().toString() !== '' && e.toString().toLowerCase().indexOf(mapObj[d as string][2].toString().toLowerCase().trim().split("~")[0]) !== -1) ? mapObj[d as string][2].trim().split("~")[1].toString() : mapObj[d as string][0].toString();
let y = h.toString();
switch (y) {
case "Active": y = "Open"; break;
case "Cancelled": y = "Cancelled"; break;
case "Completed": y = "Complete"; break;
default: y = "Check"; break;
}
ar.push([b, a, d, e, f, g, , , , , , y, , x, , , , c, k, m]);
}
return ar;
}, []);
// if new studies found, append them to Study Report sheet
if (putValues.length !== 0) {
StudyTable.addRows(-1, putValues);
}
}
...