Posted 24 July 2025, 1:45 pm EST - Updated 24 July 2025, 1:51 pm EST
Because I am no longer adding data to the sheet via:
sheet.setDataSource(data[i].data);
and adding the data manually… is there a way to filter everything but the column headers that I have stuck in the sheet?
The popup window includes the the first row which is the header… which is expected…I guess.
Is there a way to not include the first header row.
Here is basically how I am populating the sheet from data in an HTTP request (GET|POST)
//PUT COLUMN NAME in first row:
sheet.name("Queue Data Report");
// Clear the sheet first
sheet.clear();
// Get column names from the first object in your JSON array
const columnNames = Object.keys(spreadJsData[0]);
// Write column names into row 0
columnNames.forEach((colName, colIndex) => {
sheet.setValue(0, colIndex, colName); // Row 0, Column colIndex
});
// Write data starting from row 1
spreadJsData.forEach((rowData, rowIndex) => {
columnNames.forEach((colName, colIndex) => {
sheet.setValue(rowIndex + 1, colIndex, rowData[colName]); // Row starts at 1
});
});
sheet.options.protectionOptions = {
allowResizeColumns: true
};
// Lock specific columns (e.g., first 6)
sheet.options.isProtected = true;
sheet.getRange(-1, -1, -1, -1).locked(false); // Unlock all first
for (let i = 0; i < columnNames.length; i++) {
if (i < 6) {
sheet.getRange(-1, i, -1, 1).locked(true);
}
}
// Lock last column
sheet.getRange(-1, columnNames.length - 1, -1, 1).locked(true);
// Auto-fit columns
for (let j = 0; j < columnNames.length; j++) {
sheet.autoFitColumn(j);
let columnWidth = Math.max(sheet.getColumnWidth(j), columnNames[j].length * 10);
sheet.setColumnWidth(j, columnWidth);
//Also alow resizing of columns:
sheet.setColumnResizable(j, true);
}
sheet.options.colHeaderVisible = true;
// Resume painting
spread.resumeEvent();
spread.resumePaint();