My question is, how can I modify this code to fetch all columns from the array instead of just [0,1,2,3]
Here is the line of code in question:
const new_table = [0,1,2,3].map(x => make_row_from_col(this_table, x)).join('\n');
Using object.keys(this_table) does NOT work as it only displays 4 rows.
Here is the complete script:
function Test() {
const sSheet = SpreadsheetApp.getActiveSpreadsheet();
const srcSheet = sSheet.getSheetByName("Refinery");
const table = srcSheet.getRange("A:H").getValues(); // use "D2:M" if you have a header
const values_C = table.filter(t => t[7] == "READY TO SELL").map(t => t[0]);
const values_D = table.filter(t => t[7] == "READY TO SELL").map(t => t[1]);
const values_E = table.filter(t => t[7] == "READY TO SELL").map(t => t[2]);
const values_F = table.filter(t => t[7] == "READY TO SELL").map(t => t[3]);
Logger.log(values_C)
Logger.log(values_D)
Logger.log(values_E)
Logger.log(values_F)
Logger.log(values_C.length)
const this_table = [values_C,values_D,values_E,values_F];
const make_row_from_col = (this_table, col) => this_table.map(x => x[col]).join("\t"+"\t" + " | "+"\t"+"\t");
const new_table = Object.keys(this_table).map(x => make_row_from_col(this_table, x)).join('\n');
Logger.log(new_table);
}
THIS IS THE TABLE https://i.sstatic.net/Pt81F.png
Here is the LOG of the script and the desired output: https://i.sstatic.net/QLG7P.png