ワークシートがパスワードで保護されているかどうかを検出する

Contents
[ ]

Aspose.Cells for Python via .NETは、Protection.is_protected_with_password プロパティを公開しており、これによりワークシートがパスワード保護されているかどうかを確認できます。Boolean型の Protection.is_protected_with_password プロパティは、ワークシートがパスワード保護されていればtrueを返し、そうでなければfalseを返します。

from aspose.cells import Workbook
# 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 an instance of Workbook and load a spreadsheet
book = Workbook(dataDir + "sample.xlsx")
# Access the protected Worksheet
sheet = book.worksheets[0]
# Check if Worksheet is password protected
if sheet.protection.is_protected_with_password:
print("Worksheet is password protected")
else:
print("Worksheet is not password protected")