我正在尝试连接由分隔的两列,
并将结果回发到第三列
我正进入(状态:
colA colb concatenated
aa bb ww ww aa bb, ww ww
mm m,
qq ,qq
zz oo zz oo,
,
ss vv zz ss, vv zz
如何删除不需要的分隔符和空格,所以我得到:
colA colb concatenated
aa bb ww ww aa bb, ww ww
mm mm
qq qq
zz oo zz oo
ss vv zz ss, vv zz
如果这里有帮助,请提供包含一些数据的 Google 表格 https://docs.google.com/spreadsheets/d/12Hn9bVy5GmRTVxMcrZ_bdkVSlfrem-Jr4cyev_gg6BE/edit?usp=sharing
谢谢
function ConCat() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Elements");
var lc = sheet.getLastColumn();
var lr = sheet.getLastRow();
var values = sheet.getRange(2, 1, lr,lc).getValues();
var result = []; //Create a empty array to be filled concatenated elements
//Add items to results
for(var i=0; i<lr; i++){
result[i] = [values[i][0]+", "+values[i][1]];
}
//Post back to column 3 starting on row 2
sheet.getRange(2, 3, lr, 1).setValues(result);
}