暗号化されたファイルのパスワードを確認する
Contents
[
Hide
]
Excel(xlsx、xlsb、xls、xlsm)およびOpen Office(ODS)ファイルがパスワードでロックされている場合、Asposeはファイルの特定のデータを解析せずに簡単なパスワード検証をサポートしています。
暗号化されたファイルのパスワードを確認します
暗号化されたファイルのパスワードを確認するには、Aspose.Cells for Python via .NETがverify_passwordメソッドを提供します。これらのメソッドは、ファイルストリームと検証したいパスワードの2つのパラメータを受け取ります。 以下のコードスニペットは、提供されたパスワードが有効かどうかを確認するverify_passwordメソッドの使用を示しています。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import FileFormatUtil | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create a Stream object | |
fstream = open(dataDir + "EncryptedBook1.xlsx", "rb") | |
isPasswordValid = FileFormatUtil.verify_password(fstream, "1234") | |
print("Password is Valid: " + str(isPasswordValid)) |