/// <summary> /// Sets a password for the sheet. /// </summary> /// <param name="Password"></param> public void SetPassword(string Password) { if (IsProtected == false) { IsProtected = true; } Password = Password.Trim(); if (Password == "") { string passwordPath = "d:sheetProtection"; XmlNode node = TopNode.SelectSingleNode(passwordPath, NameSpaceManager); if (node != null) { TopNode.RemoveChild(node); //node.OwnerDocument.Attributes.Remove(node as XmlAttribute); //(node as XmlAttribute).OwnerElement.Attributes.Remove(node as XmlAttribute); } return; } int hash = EncryptedPackageHandler.CalculatePasswordHash(Password); SetXmlNodeString(_passwordPath, ((int)hash).ToString("x")); }
/// <summary> /// Sets a password for the sheet. /// </summary> /// <param name="Password"></param> public void SetPassword(string Password) { #if CORECLR throw new NotSupportedException(); #else if (IsProtected == false) { IsProtected = true; } Password = Password.Trim(); if (Password == "") { var node = TopNode.SelectSingleNode(_passwordPath, NameSpaceManager); if (node != null) { (node as XmlAttribute).OwnerElement.Attributes.Remove(node as XmlAttribute); } return; } int hash = EncryptedPackageHandler.CalculatePasswordHash(Password); SetXmlNodeString(_passwordPath, ((int)hash).ToString("x")); #endif }
/// <summary> /// Sets a password for the workbook. This does not encrypt the workbook. /// </summary> /// <param name="Password">The password. </param> public void SetPassword(string Password) { if (string.IsNullOrEmpty(Password)) { DeleteNode(workbookPasswordPath); } else { SetXmlNodeString(workbookPasswordPath, ((int)EncryptedPackageHandler.CalculatePasswordHash(Password)).ToString("x")); } }
/// <summary> /// Sets a password for the workbook. This does not encrypt the workbook. /// </summary> /// <param name="Password">The password. </param> public void SetPassword_Kevin(string Password) { if (string.IsNullOrEmpty(Password)) { string passwordPath = "d:fileSharing"; DeleteNode(passwordPath); } else { SetXmlNodeString(workbookPasswordPath_Kevin, ((int)EncryptedPackageHandler.CalculatePasswordHash(Password)).ToString("x")); } }
/// <summary> /// Sets a password for the workbook. This does not encrypt the workbook. /// </summary> /// <param name="Password">The password. </param> public void SetPassword(string Password) { if (string.IsNullOrEmpty(Password)) { DeleteNode(workbookPasswordPath); } else { #if CORECLR throw new NotSupportedException(); #else SetXmlNodeString(workbookPasswordPath, ((int)EncryptedPackageHandler.CalculatePasswordHash(Password)).ToString("x")); #endif } }