简体   繁体   中英

Google Sheets: show different rows for specific users

Is there a way, to make certain rows in Google Spreadsheets, be editable and accessible to a certain user, while not be accessible to another user?

I have a spreadsheet which 70 or so people need to access and input their data into the rows that are allocated to them. Previously, I just protected each row so that they couldn't edit anyone else's rows but ideally I would also like to hide everyone else's rows. Example spreadsheet here .

At the moment, I've tried to use a script to hide and show certain rows depending on the email address of the person accessing the spreadsheet. However, this affects the view of everyone looking at the spreadsheet currently. My code is:

    function onOpen(e){
        var email = (Session.getEffectiveUser().getEmail());
        var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

        switch (email){
             case 'user1@email.com':
             sheet.hideRows(7, sheet.getMaxRows()-6);
             break;
        case 'user2@email.com':
             sheet.hideRows(2, 5);
             sheet.showRows(7, 5);
             sheet.hideRows(12, sheet.getMaxRows()-11);
             break;
        case 'user3@email.com':
             sheet.hideRows(2, 10);
             sheet.showRows(12, 5);
             sheet.hideRows(17, sheet.getMaxRows()-16);
             break; 

...etc.

My question is: is there a way to make these views viewer-specific rather than global? Or am I doomed to go through each row and just use the protection feature every time I need to generate this spreadsheet?

Why not use a form attached to the sheet? It will keep users from overwriting other responses, hide other responses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM