I have a Google Sheets worksheet that contains certain values that should ideally only be revealed to people who have Edit capability. For example, there is a "next row to be processed" cell that's present for restarts. There is also a sheet where some maintenance items may be placed (for example, renames of items in the main sheet), and so on. It would be preferable to not reveal that information (nor even its existence). So I tried this code:
function onOpen() {
var menuItems ;
var spreadsheet = SpreadsheetApp.getActive();
if (spreadsheet.getDataRange().canEdit()) {
menuItems = [
{name: 'Process all rows from the top' , functionName: 'processAllStreams'}
, {name: 'Resume processing at row #' , functionName: 'processStreams'}
// other stuff
];
spreadsheet.addMenu('Process it', menuItems);
if (replacementsSheet) {
replacementsSheet.showSheet();
}
for (var c=0; c < MAINSHEET_NBR_MAINTENANCE_COLUMNS; c++) {
mainSheet.unhideColumn(MAINSHEET_MAINTENANCE_START_COLUMN + c) ;
}
}
else {
mainSheet.hideColumns(MAINSHEET_MAINTENANCE_START_COLUMN, MAINSHEET_NBR_MAINTENANCE_COLUMNS) ;
if (replacementsSheet) {
replacementsSheet.hideSheet();
}
}
}
But of course, those who cannot edit the spreadsheet cannot perform those functions in the else clause. How do others handle the situation where you want the presentation to be different for the public versus the operational aspects?
Can operate without these niceties, but it looks a little unprofessional as is.