密码保护或取消保护共享工作簿
可能的使用场景
您可以使用 Microsoft Excel 保护或取消保护共享工作簿,如以下屏幕截图所示。 Aspose.Cells 也支持此功能[工作簿.protectSharedWorkbook() ](https://reference.aspose.com/cells/java/com.aspose.cells/workbook#protectSharedWorkbook(java.lang.String) ) 和[工作簿.unprotectSharedWorkbook() ](https://reference.aspose.com/cells/java/com.aspose.cells/workbook#unprotectSharedWorkbook(java.lang.String) ) 方法。
密码保护或取消保护共享工作簿
以下示例代码创建一个工作簿并在启用共享的同时对其进行保护并将其另存为输出Excel文件 .截图显示,当你尝试取消保护时,Microsoft 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
// 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");