Compartir a través de


WorkbookBase.PasswordEncryptionProvider (Propiedad)

Obtiene el nombre del proveedor del algoritmo de cifrado que utiliza Microsoft Office Excel cuando cifra contraseñas para el libro.

Espacio de nombres:  Microsoft.Office.Tools.Excel
Ensamblado:  Microsoft.Office.Tools.Excel.v4.0.Utilities (en Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Sintaxis

'Declaración
Public ReadOnly Property PasswordEncryptionProvider As String
public string PasswordEncryptionProvider { get; }

Valor de propiedad

Tipo: System.String
Nombre del proveedor del algoritmo de cifrado que utiliza Excel cuando cifra contraseñas para el libro.

Ejemplos

El ejemplo de código siguiente comprueba el valor de la propiedad HasPassword para determinar si el libro está protegido con contraseña.Si el libro no está protegido con contraseña, el ejemplo establece la propiedad Password en una contraseña obtenida a partir de los datos proporcionados por el usuario y, a continuación, llama al método SetPasswordEncryptionOptions para establecer el algoritmo de cifrado, establecer la longitud de la clave, establecer el nombre del proveedor de cifrado y habilitar el cifrado de la propiedad del archivo.A continuación, el ejemplo muestra los valores de las propiedades PasswordEncryptionProvider, PasswordEncryptionAlgorithm, PasswordEncryptionKeyLength y PasswordEncryptionFileProperties en la hoja de cálculo Sheet1.Este ejemplo supone que se ha definido el método GetPasswordFromUserInput en otra parte.

Se trata de un ejemplo para una personalización en el nivel del documento.

Private Sub WorkbookPasswordOptions()
    If Not Me.HasPassword Then
        Me.Password = GetPasswordFromUserInput()
        Me.SetPasswordEncryptionOptions( _
            "Microsoft RSA SChannel Cryptographic Provider", _
            "RC4", 128, True)
    End If

    ' Display the password properties in Sheet1.
    Globals.Sheet1.Range("A1").Value2 = _
        "Password Encryption Provider:"
    Globals.Sheet1.Range("A2").Value2 = _
        "Password Encryption Algorithm:"
    Globals.Sheet1.Range("A3").Value2 = _
        "Password Encryption Key Length:"
    Globals.Sheet1.Range("A4").Value2 = _
        "Password Encryption File Properties:"
    Globals.Sheet1.Range("A1", "A4").Columns.AutoFit()

    Globals.Sheet1.Range("B1").Value2 = _
        Me.PasswordEncryptionProvider
    Globals.Sheet1.Range("B2").Value2 = _
        Me.PasswordEncryptionAlgorithm
    Globals.Sheet1.Range("B3").Value2 = _
        Me.PasswordEncryptionKeyLength
    Globals.Sheet1.Range("B4").Value2 = _
        Me.PasswordEncryptionFileProperties
    Globals.Sheet1.Range("B1", "B4").Columns.AutoFit()
End Sub
private void WorkbookPasswordOptions()
{
    if (!this.HasPassword)
    {
        this.Password = GetPasswordFromUserInput();
        this.SetPasswordEncryptionOptions(
            "Microsoft RSA SChannel Cryptographic Provider",
            "RC4", 128, true);
    }

    // Display the password properties in Sheet1.
    Globals.Sheet1.Range["A1"].Value2 =
        "Password Encryption Provider:";
    Globals.Sheet1.Range["A2"].Value2 =
        "Password Encryption Algorithm:";
    Globals.Sheet1.Range["A3"].Value2 =
        "Password Encryption Key Length:";
    Globals.Sheet1.Range["A4"].Value2 =
        "Password Encryption File Properties:";
    Globals.Sheet1.Range["A1", "A4"].Columns.AutoFit();

    Globals.Sheet1.Range["B1"].Value2 =
        this.PasswordEncryptionProvider;
    Globals.Sheet1.Range["B2"].Value2 =
        this.PasswordEncryptionAlgorithm;
    Globals.Sheet1.Range["B3"].Value2 =
        this.PasswordEncryptionKeyLength;
    Globals.Sheet1.Range["B4"].Value2 =
        this.PasswordEncryptionFileProperties;
    Globals.Sheet1.Range["B1", "B4"].Columns.AutoFit();
}

Seguridad de .NET Framework

Vea también

Referencia

WorkbookBase Clase

Microsoft.Office.Tools.Excel (Espacio de nombres)