Luc*_*ida 4 arrays google-sheets google-apps-script
我一直在谷歌应用程序脚本上编写一个表格:
function basePesa(){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("aux");
var unique = sheet.getRange("C1").setFormula("=unique(A:A)");
var Avals = sheet.getRange("C1:C").getValues();
var Alast = Avals.filter(String).length;
var transp = sheet.getDataRange().getValues();
var ss = SpreadsheetApp.openById("14Y3xiAa9kdoK_YO_tAVN-YWC9RE1EANV5wm8Ez1sa1o");
var base =ss.getSheetByName("Base PESA");
var values = base.getDataRange().getValues();
var newdata = new Array(values.length);
var y = 0;
// Browser.msgBox(transp.length);
for(var i=0;i<Alast;i++){
var tra = Avals[i][0];
for(var x =1; x<values.length;x++){
if(values[x][18] == tra){
newdata[y] = new Array(values[0].length);
for(var p=0; p<values[0].length;p++)
newdata[y][p] = values[x][p];
y++;
}
}
}
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Bco de Dados").getRange("A2:AZ"+(y+1)+"").setValues(newdata);
// Browser.msgBox(newdata);
}
Run Code Online (Sandbox Code Playgroud)
似乎我无法将数组写入范围.我已经检查了范围是否匹配以及我确定这个数组是2D数组.有没有指示?
提前致谢!
小智 7
数组1:[A,B,C] <----兼容1行3列
数组2:[[A],[B],[C]] <---兼容3行,1列
数组3:[[A,B,C],[A,B,C],[A,B,C]] <---兼容3行,3列**
**需要注意的是,较大阵列中每个较小阵列的宽度(在本例中为3)对于每个较小的阵列必须相同.
| 归档时间: |
|
| 查看次数: |
5523 次 |
| 最近记录: |