ChartSheetProtection.Password Property
Password.Represents the attribte in schema: password
Namespace: DocumentFormat.OpenXml.Spreadsheet
Assembly: DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)
Syntax
'Declaration
<SchemaAttrAttribute(, "password")> _
Public Property Password As HexBinaryValue
Get
Set
'Usage
Dim instance As ChartSheetProtection
Dim value As HexBinaryValue
value = instance.Password
instance.Password = value
[SchemaAttrAttribute(, "password")]
public HexBinaryValue Password { get; set; }
Property Value
Type: DocumentFormat.OpenXml.HexBinaryValue
Returns StringValue.
Remarks
The following information from the ECMA International Standard ECMA-376 can be useful when working with this class.
Specifies the hash of the password required for editing this chart sheet. This protection is optional and may be ignored by applications that choose not to support this functionality. The hash is generated from an 8-bit wide character. 16-bit Unicode characters must be converted down to 8 bits before the hash is computed, using the logic defined in the revisionsPassword attribute of the workbookProtection element.
The resulting value is hashed using the algorithm defined below.
An example algorithm to hash the user input into the value stored is as follows:
// Function Input:
// szPassword: NULL-terminated C-style string
// cchPassword: The number of characters in szPassword (not including the NULL terminator)
WORD GetPasswordHash(const CHAR *szPassword, int cchPassword) {
WORD wPasswordHash;
const CHAR *pch;
wPasswordHash = 0;
if (cchPassword > 0)
{
pch = &szPassword[cchPassword];
while (pch-- != szPassword)
{
wPasswordHash = ((wPasswordHash >> 14) & 0x01) | ((wPasswordHash << 1) & 0x7fff);
wPasswordHash ^= *pch;
}
wPasswordHash ^= (0x8000 | ('N' << 8) | 'K');
}
return(wPasswordHash);
}
The possible values for this attribute are defined by the ST_UnsignedShortHex simple type.