我很难将这个小功能添加到我的工作中:
基本上,如果data [i] [49]为空白,我想将名称“Clay”分配给它,否则将数据[i] [49]分配给它。我已经尝试将它放在多个位置,它只是将整个函数体插入到我的电子表格中。
感谢您的帮助!
var whywontthiswork = (function {if(data[i][49] == " "){
"Clay"
}else{
data[i][49]
};})
它一直说“无效的属性ID。(第27行,文件”C1:推送加载详细信息“)”
function pushLoadDetails() {
deleteCSV();
//allPlainTextFormat(); adds 20 seconds
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh0 = ss.getSheetByName("Loads"), sh1 = ss.getSheetByName("DAT"), sh2 = ss.getSheetByName("Truckstop"),
sh3 = ss.getSheetByName("Posteverywhere"),sh4 = ss.getSheetByName("Push"), sh5 = ss.getSheetByName("Carriers");
// get data from Loads sheet
var data = sh0.getRange(8,4,33,55).getValues();
// create array to hold data (imaginary)
var aMain = new Array();
var bMain = new Array();
var myArray = aMain;
// itterate through data and add to array
//for (var i = 0, len = myArray.length; i < len; i++) {}
for(var i=0; i < 31; i++) { //Controls how many rows it goes through for posting // len = data.length; i < len
var whywontthiswork = (function {if(data[i][49] == " "){
"Clay"
}else{
data[i][49]
};})
if(i != ""){
for(var j=25; j<28; j++) { //Controls which date elements to iterate through for posting
for(var k=32; k<37; k++) { //Controls which trailer type elements to iterate through for posting
var aPushArray = [data[i][0],data[i][1],data[i][2],data[i][3],data[i][4],data[i][5],data[i][6],data[i][7],data[i][8],data[i][9],
data[i][10],data[i][11],data[i][12],data[i][13],data[i][14],data[i][15],data[i][16],data[i][17],data[i][18],data[i][19],
data[i][20],data[i][21],data[i][22],data[i][23],data[i][24],data[i][j],//data[i][25],//data[i][26],data[i][27],
data[i][28],data[i][29],
data[i][30],data[i][31],data[i][k],//data[i][32],data[i][33],data[i][34],data[i][35],data[i][36],
data[i][37],data[i][38],data[i][39],
data[i][40],data[i][41],data[i][42],data[i][43],data[i][44],data[i][45],
data[i][46],data[i][47],data[i][48],[whywontthiswork]//data[i][49]
]
//[Utilities.formatDate(new Date(), "GMT+8", "ddMMyyyyHHmmssSSS")] can go over data[i][44] to make consecutive numbers
//var aJK = Logger.log(aPushArray[0].length);
//var aWidth = return aJK;
//ts = aPushArray.split(',');
var aPush = aMain.push(aPushArray); //add more data sets to import more columns of data
};
};
};
};
// function pushCarrierInfo(){
for(var i=0; i < 31; i++) {
if(i != ""){ //Controls how many rows it goes through for posting
//Controls which trailer type elements to iterate through for posting
deleteSheet("Carriers","A2:AZ")
var bPush = bMain.push(
[data[i][49],data[i][46],data[i][48],data[i][47],
data[i][0],data[i][1],data[i][2],data[i][3],data[i][4],data[i][5],data[i][6],data[i][7],data[i][8],//data[i][9],
//data[i][10],data[i][11],data[i][12],data[i][13],data[i][14],data[i][15],data[i][16],data[i][17],data[i][18],
data[i][19],
//data[i][20],data[i][21],data[i][22],data[i][23],data[i][24],data[i][25],data[i][26],data[i][27],
data[i][28],data[i][29],
data[i][30],data[i][31],//data[i][32],data[i][33],data[i][34],data[i][35],data[i][36],
data[i][37],data[i][38],data[i][39],
data[i][40],data[i][41],data[i][42],data[i][43],data[i][44],data[i][45]//,data[i][46],data[i][48],data[i][49],
//data[i][50],data[i][51],data[i][52],data[i][53]
]); //add more data sets to import more columns of data
};
};
// };
//var aWidth = Logger.log(aPushArray[0].length);
//var bWidth = Logger.log(bPush[0].length);
// add array of data to second sheet. final column length must match # of data sets
sh4.getRange(2, 1, aMain.length, 44).setValues(aMain);
sh5.getRange(2, 1, bMain.length, 27).setValues(bMain);
deleteSheet("Posteverywhere","A3:Z")
//allPlainTextFormat(); adds 20 seconds
//var ss = SpreadsheetApp.getActive();
var ssk = SpreadsheetApp.openById("15bdmuKR9aHZyjffpzN0wFqhnJf6klFmni64OnA3HEEo");
var shk = ssk.getSheetByName("Posteverywhere");
var thissheet = ss.getSheetByName("Posteverywhere"); //row, column, numRows, numColumns
//var thissheet = thisSheet.getRange(4,1,50,30);
// get data from Loads sheet
var dataK = shk.getRange(1,1,34,52).getValues();
//create array to hold data (imaginary)
var koturMain = new Array();
// itterate through data and add to array
for(var i=0; i < 31; i++) {
if(i != ""){ //Controls how many rows it goes through for posting
//Controls which trailer type elements to iterate through for posting
var koturPE = koturMain.push([dataK[i][0],dataK[i][1],dataK[i][2],dataK[i][3],dataK[i][4],dataK[i][5],dataK[i][6],dataK[i][7],dataK[i][8],dataK[i][9],
dataK[i][10],dataK[i][11],dataK[i][12],dataK[i][13],dataK[i][14],dataK[i][15],dataK[i][16],dataK[i][17],dataK[i][18],dataK[i][19],
dataK[i][20],dataK[i][21],dataK[i][22],dataK[i][23],dataK[i][24],dataK[i][25],dataK[i][26],dataK[i][27],dataK[i][28],dataK[i][29],
dataK[i][30],//data[i][31],//data[i][32],data[i][33],data[i][34],data[i][35],data[i][36],
//data[i][37],data[i][38],data[i][39],
//data[i][40],data[i][41],data[i][42],data[i][43],data[i][45],data[i][44],//data[i][46],data[i][47],data[i][48],data[i][49]
]); //add more data sets to import more columns of data
};
};
// add array of data to second sheet. final column length must match # of data sets
// thissheet.getRange(thissheet.getLastRow()+1, 1, koturMain.length, 25).setValues(koturMain);
};
答案 0 :(得分:0)
在尝试了很多事情后,我意识到这将完成工作而不会增加处理时间并且不得不混淆格式化或插入任何功能。
使用或“||”符号是和if / else语句。
[data[i][49]||"Clay"]