WorkbookBase.PasswordEncryptionProvider 屬性
取得當 Microsoft Office Excel 加密活頁簿密碼時所使用的演算法加密提供者名稱。
命名空間: Microsoft.Office.Tools.Excel
組件: Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)
語法
'宣告
Public ReadOnly Property PasswordEncryptionProvider As String
public string PasswordEncryptionProvider { get; }
屬性值
型別:System.String
當 Excel 加密活頁簿密碼時所使用的演算法加密提供者名稱。
範例
下列程式碼範例檢查 HasPassword 屬性的值,判斷活頁簿是否已設定密碼保護。如果活頁簿未設定密碼保護,則此範例會將 Password 屬性設為使用者輸入的密碼,然後呼叫 SetPasswordEncryptionOptions 方法,設定加密 (Encryption) 演算法、金鑰 (Key) 長度、加密提供者名稱,並啟用檔案屬性加密。然後此範例會在工作表 Sheet1 中顯示 PasswordEncryptionProvider、PasswordEncryptionAlgorithm、PasswordEncryptionKeyLength 和 PasswordEncryptionFileProperties 屬性的值。此範例假設在其他地方定義 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。