共有ブックをパスワードで保護または保護解除

可能な使用シナリオ

以下のスクリーンショットに示すように、Microsoft Excelを使用して共有ワークブックを保護または保護解除することができます。Aspose.Cellsもこの機能をWorkbook.protectSharedWorkbook()およびWorkbook.unprotectSharedWorkbook()メソッドでサポートしています。

todo:image_alt_text

共有ワークブックのパスワード保護または保護解除

次のサンプルコードはワークブックを作成し、共有を有効にして保護し、出力Excelファイルとして保存します。スクリーンショットには、保護を解除しようとすると、Microsoft Excelが保護解除のパスワード入力を求める様子が示されています。

todo:image_alt_text

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Create empty Excel file
Workbook wb = new Workbook();
//Protect the Shared Workbook with Password
wb.protectSharedWorkbook("1234");
//Uncomment this line to Unprotect the Shared Workbook
//wb.unprotectSharedWorkbook("1234");
//Save the output Excel file
wb.save("outputProtectSharedWorkbook.xlsx");