Correct way to protect workbook after load

Hello,

I don't understand what is the correct way to prevent the user from updating all the sheets in a workbook after loading them.

The property isProtected can't be applied to the whole workbook.

The method protectSheet takes a number or a string in argument, but I don't understand what the number should be, I tried 0 or 1 but only the active sheet is protected. And when using the method multiple time with the sheets name it also only freeze the current sheet.

My goal is to :

- Define the spreadsheet component
- Load the workbook and its spreadsheet(s) using openFromJson
- Protect all the sheets

What would be the correct way to do that in VueJS?

Thanks,
Tuan

3 Replies 1 reply marked as answer

SP Sangeetha Priya Murugan Syncfusion Team April 8, 2021 08:29 AM UTC

Hi Taun, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your reported requirement and it can be achievable in our spreadsheet by using the protectSheet method in actionComplete event as like as below. In this we have apply the protect sheet in actionComplete event for the switched sheets. 
 
 
<ejs-spreadsheet 
        ref="spreadsheet" 
        :created="created" 
        :actionComplete="actionComplete" 
        :heigth="height" 
      > 
      </ejs-spreadsheet> 
 
 
created: function () { 
      var spreadsheet = this.$refs.spreadsheet; 
      var parsedData = JSON.parse(this.response); // Parse the stringified response 
      spreadsheet.openFromJson({ 
        file: parsedData, 
      }); 
      // To protect the active sheet. 
      spreadsheet.protectSheet(1, this.protectSetting); 
       
    }, 
    actionComplete: function (args) { 
      var spreadsheet = this.$refs.spreadsheet; 
      // To protect the switched sheets 
      if (args.action === "gotoSheet") 
        spreadsheet.protectSheet( 
          args.eventArgs.currentSheetIndex, 
          this.protectSetting 
        ); 
    }, 
 
 
For your convenience, we have prepared the sample based on our suggestion. Please find the link below. 
 
 
Could you please check the above links and get back to us, if you need any further assistance on this. 
 
Regards, 
Sangeetha M 


Marked as answer

TA Tuan Ardouin April 8, 2021 09:41 AM UTC

Hi,

Thanks for your quick answer. It works like a charm if I change it a bit : 

In the created method it should be a `0` right ? 
      spreadsheet.protectSheet(0, this.protectSetting); 

It only works if I put the index 0, even is the default opened sheet is not at index 0.

Thanks,
Tuan


SP Sangeetha Priya Murugan Syncfusion Team April 9, 2021 05:57 AM UTC

Hi Tuan, 
 
Thank you for your update. 
 
We have checked your suggestion and we would like to let you know that the protectSheet applied for active sheet only. So, only we have suggested to apply the protectSheet option in page switch actionComplete event.  Please get back to us if you need any further assistance on this. 
 
Regards, 
Sangeetha M 


Loader.
Up arrow icon