Aracılığıyla paylaş


WorkbookBase.HasPassword Özellik

Çalışma kitabını koruma parolası olup olmadığını gösteren bir değeri alır.

Ad alanı:  Microsoft.Office.Tools.Excel
Derleme:  Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll içinde)

Sözdizimi

'Bildirim
Public ReadOnly Property HasPassword As Boolean
public bool HasPassword { get; }

Özellik Değeri

Tür: System.Boolean
true çalışma kitabını koruma parolası yoksa; Aksi halde, false.

Örnekler

Aşağıdaki kod örneği değerini kontrol eder HasPassword çalışma kitabı parola korumalı olup olmadığını belirlemek için özellik.Çalışma kitabı parola korumalı ise, daha sonra örnek ayarlar Password özelliği parola için kullanıcı girişi elde edilen ve daha sonra SetPasswordEncryptionOptions şifreleme algoritması yöntem anahtar uzunluğunu ayarlama, şifreleme sağlayıcısının adını ayarlamak ve dosya özelliği şifrelemeyi etkinleştirin.Örnek sonra değerlerini görüntüler PasswordEncryptionProvider, PasswordEncryptionAlgorithm, PasswordEncryptionKeyLength, ve PasswordEncryptionFileProperties çalışma özellikleri Sheet1.Bu örnekte, adlı bir yöntemin varlığı kabul GetPasswordFromUserInput , güçlü bir parola kullanıcı girişi alır.

Bu örnek için belge düzeyi özelleştirmesinde içindir.

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 Güvenliği

Ayrıca bkz.

Başvuru

WorkbookBase Sınıf

Microsoft.Office.Tools.Excel Ad Alanı