简体   繁体   English

Google 表格:为特定用户显示不同的行

[英]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?有没有办法使 Google 电子表格中的某些行可编辑并可被某个用户访问,而不能被其他用户访问?

I have a spreadsheet which 70 or so people need to access and input their data into the rows that are allocated to them.我有一个电子表格,大约 70 个人需要访问该电子表格并将他们的数据输入到分配给他们的行中。 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.它将防止用户覆盖其他响应,隐藏其他响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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