I want a report with a few selected columns from a sheet.
The selection will be as per the user input like "1,4,7,12" for including column 1,4,7 and 12 in the report.
Or the input can be "2,3" to include column 2 and 3 in the report.
//user input is saved in variable input "1,4,7,8" or "2,4" or "3,2,5"
//
var jobvals = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getDataRange().getValues();
var flds=input.split(",");
var tstr="";
for (i=1;i<jobvals.length;i++){
for (s=0;s<flds.length;s++){
//tstr+=jobvals[i][flds[s]]+","; //I can make a comma separated string for each row. But, I want an array for further processing
//getting stuck here - how to make an array
}
tstr+="\n";
}
I want to make a new array with the selected columns. The number of columns in the result array will vary. And, the column selection will also vary.
Appreciate some ideas how to achieve this.