ワークシートの保護と保護解除
Contents
[
Hide
]
ワークシート上のデータの変更、移動、または削除を他のユーザーが誤ってまたは意図的に防ぐために、Excelワークシートのセルをロックし、その後シートをパスワードで保護できます。
MS Excelでのワークシートの保護と保護解除
- レビュー > ワークシートの保護 をクリックします。
- パスワードボックス にパスワードを入力します。
- 許可 オプションを選択します。
- OK を選択し、パスワードを再入力して確認し、その後再度 OK を選択します。
Aspose.Cells for Pythonを使用してワークシートを保護する
Excelファイルのワークシートの構造を保護するためには、次の簡単なコード行のみが必要です。
This file contains 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
#Create a new file. | |
workbook = Workbook() | |
#Gets the first worksheet. | |
sheet = workbook.getWorksheets().get(0) | |
#Protect contents of the worksheet. | |
sheet.protect(ProtectionType.CONTENTS) | |
#Protect worksheet with password. | |
sheet.getProtection().setPassword('test') | |
#Save as Excel file. | |
workbook.save('Book1.xlsx') |
Aspose.Cells for Pythonを使用してワークシートの保護を解除する
Aspose.Cells APIを使えば、ワークシートの保護の解除は簡単です。ワークシートがパスワードで保護されている場合、正しいパスワードが必要です。
This file contains 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
#Create a new file. | |
workbook = Workbook("Book1.xlsx") | |
#Gets the first worksheet. | |
sheet = workbook.getWorksheets().get(0) | |
#Protect contents of the worksheet. | |
sheet.unprotect("password") | |
#Save Excel file. | |
workbook.save("Book1.xlsx") |