public IXLSheetProtection AllowElement(XLSheetProtectionElements element, bool allowed = true)
        {
            if (!allowed)
            {
                return(DisallowElement(element));
            }

            AllowedElements |= element;
            return(this);
        }
 public IXLSheetProtection DisallowElement(XLSheetProtectionElements element)
 {
     AllowedElements &= ~element;
     return(this);
 }
Example #3
0
 IXLElementProtection <XLSheetProtectionElements> IXLElementProtection <XLSheetProtectionElements> .DisallowElement(XLSheetProtectionElements element) => DisallowElement(element);
Example #4
0
        public IXLSheetProtection Protect(String password, Algorithm algorithm = DefaultProtectionAlgorithm, XLSheetProtectionElements allowedElements = XLSheetProtectionElements.SelectEverything)
        {
            if (IsProtected)
            {
                throw new InvalidOperationException("The worksheet is already protected");
            }
            else
            {
                IsProtected = true;

                password = password ?? "";

                this.Algorithm         = algorithm;
                this.Base64EncodedSalt = Utils.CryptographicAlgorithms.GenerateNewSalt(this.Algorithm);
                this.PasswordHash      = Utils.CryptographicAlgorithms.GetPasswordHash(this.Algorithm, password, this.Base64EncodedSalt, this.SpinCount);
            }

            this.AllowedElements = allowedElements;

            return(this);
        }
Example #5
0
 IXLElementProtection <XLSheetProtectionElements> IXLElementProtection <XLSheetProtectionElements> .AllowElement(XLSheetProtectionElements element, Boolean allowed) => AllowElement(element, allowed);