WorkbookBase.EncryptionProvider 属性

获取 Microsoft Office Excel 用来加密工作簿密码的算法加密提供程序的名称。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

语法

声明
Public Property EncryptionProvider As String
public string EncryptionProvider { get; set; }

属性值

类型:System.String
Excel 用来加密工作簿密码的算法加密提供程序的名称。

示例

下面的代码示例检查 HasPassword 属性的值,以确定工作簿是否受密码保护。如果工作簿不受密码保护,则此示例将 Password 属性设置为从用户输入获得密码,然后调用 SetPasswordEncryptionOptions 方法设置加密算法、密钥长度和加密提供程序的名称,并启用文件属性加密。然后,此示例在工作表 Sheet1 中显示 PasswordEncryptionProviderPasswordEncryptionAlgorithmPasswordEncryptionKeyLengthPasswordEncryptionFileProperties 属性的值。此示例假定方法 GetPasswordFromUserInput 是在别处定义的。

此示例针对的是文档级自定义项。

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();
}

.NET Framework 安全性

请参见

参考

WorkbookBase 类

Microsoft.Office.Tools.Excel 命名空间