保护和取消保护工作簿结构
Contents
[
Hide
]
为防止其他用户查看隐藏工作表、添加、移动、删除或隐藏工作表,并重命名工作表,您可以使用密码保护 Excel 工作簿的结构。
在 MS Excel 中保护和取消保护工作簿结构
- 点击 审阅 > 保护工作簿。
- 在 密码框 中输入密码。
- 选择 确定,重新输入密码以确认,然后再次选择 确定。
使用 Aspose.Cell for .Net 保护工作簿结构
只需要以下简单代码行来实现保护 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 = new Workbook(); | |
//Protect workbook structure. | |
workbook.Protect(ProtectionType.Structure, "password"); | |
//Save Excel file. | |
workbook.Save("Book1.xlsx"); |
使用 Aspose.Cell for .Net 取消保护工作簿结构
使用 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
//Open an Excel file which workbook structure is protected. | |
Workbook workbook = new Workbook("Book1.xlsx"); | |
//Unprotect workbook structure. | |
workbook.Unprotect("password"); | |
//Save Excel file. | |
workbook.Save("Book1.xlsx"); |
注意:需要正确的密码。