取消保护工作表
Contents
[
Hide
]
如果开发人员需要在运行时从受保护的工作表中删除保护,以便可以对文件进行一些更改?使用 Aspose.Cells 可以轻松完成此操作。
取消保护工作表
使用 Microsoft Excel
要取消对工作表的保护:
来自工具菜单,选择保护其次是取消保护工作表.除非工作表受密码保护,否则保护将被取消。在这种情况下,会出现一个对话框提示输入密码。输入密码,然后工作表将不受保护。
使用 Aspose.Cells 取消保护简单保护的工作表
可以通过调用工作表班级'取消保护方法。 简单保护的工作表是不受密码保护的工作表。可以通过调用取消保护不传递参数的方法。
This file contains hidden or 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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Unprotecting the worksheet without a password | |
worksheet.Unprotect(); | |
// Saving the Workbook | |
workbook.Save(dataDir + "output.xls", SaveFormat.Excel97To2003); |
使用 Aspose.Cells 取消保护受密码保护的工作表
受密码保护的工作表是受密码保护的工作表。可以通过调用重载版本的取消保护将密码作为参数的方法。
This file contains hidden or 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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(dataDir + "book1.xls"); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Unprotecting the worksheet with a password | |
worksheet.Unprotect(""); | |
// Save Workbook | |
workbook.Save(dataDir + "output.out.xls"); |