我想创建一份参加各种主题培训的候选人名单。培训师完成Google表格并从复选框列表中选择候选人,并从复选框列表中选择培训主题。结果是两个以逗号分隔的字符串,我想将其拆分为逐项数组,如下所示:
原始表单回复
| Candidate | Training |
+----------------------+-----------------------------+
| Peter, Susan, John | Algebra, Geometry, Calculus |
期望的输出:
| Candidate | Training |
+--------------+------------+
| Peter | Algebra |
| Peter | Geometry |
| Peter | Calculus |
| Susan | Algebra |
| Susan | Geometry |
| Susan | Calculus |
| John | Algebra |
| John | Geometry |
| John | Calculus |
将提交多份表单,培训师可以提交多份回复。
我自己试了一下,这就是我提出的:=ARRAYFORMULA({transpose(trim(split(join(",", rept(C2:C&",", if(len(E2:E)>0, (len(E2:E)-len(substitute(E2:E, ",",""))+1),)) ),","))),transpose(trim(split(join(",", rept(E2:E&",", if(len(C2:C)>0, (len(C2:C)-len(substitute(C2:C, ",",""))+1),)) ),",")))})
这成功地分割并重复两个字符串正确的次数,但是它以相同的顺序重复它。这个含义(参考我原来的问题中的例子)是你得到以下不良输出:
| Candidate | Training |
+--------------+------------+
| Peter | Algebra |
| Susan | Geometry |
| John | Calculus |
| Peter | Algebra |
| Susan | Geometry |
| John | Calculus |
有什么建议吗?我真诚地感谢任何人对此的帮助! 提前致谢
答案 0 :(得分:0)
你可以用jQuery做到这一点:
var url = "https://spreadsheets.google.com/feeds/cells/0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE/od6/public/values?alt=json-in-script&callback=<YOUR_CALLBACK>";
$.getJSON(url,{}, function (d) { console.log(d); });
现在&#34; d&#34;是你的对象......