密码保护或取消保护共享工作簿

可能的使用场景

您可以通过Microsoft Excel中的以下截图显示的方式保护或取消保护共享工作簿。Aspose.Cells也支持此功能,其中包括Workbook.protectSharedWorkbook()Workbook.unprotectSharedWorkbook()方法。

todo:image_alt_text

密码保护或取消保护共享工作簿

下面的示例代码创建一个工作簿并在启用共享时保护它,并将其保存为 output Excel file。屏幕截图显示,当您尝试取消保护时,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");