在 Jython 中取消保护简单保护的工作表
Contents
[
Hide
]
Aspose.Cells - 取消保护简单保护工作表
使用附加文档Aspose.Cells Java 对于 Jython.在这里您可以看到示例代码。
Jython代码
from aspose-cells import Settings
from com.aspose.cells import Workbook
from com.aspose.cells import SaveFormat
from com.aspose.cells import FileFormatType
class UnprotectingSimplyProtectedWorksheet:
def __init__(self):
dataDir = Settings.dataDir + 'WorkingWithWorksheets/UnprotectingSimplyProtectedWorksheet/'
filesFormatType = FileFormatType
#Instantiating a Workbook object
workbook = Workbook(dataDir + "Book1.xls")
worksheets = workbook.getWorksheets()
worksheet = worksheets.get(0)
protection = worksheet.getProtection()
#The following 3 methods are only for Excel 2000 and earlier formats
protection.setAllowEditingContent(False)
protection.setAllowEditingObject(False)
protection.setAllowEditingScenario(False)
#Unprotecting the worksheet
worksheet.unprotect()
# Save the excel file.
workbook.save(dataDir + "output.xls", filesFormatType.EXCEL_97_TO_2003)
#Print Message
print "Worksheet unprotected successfully."
if __name__ == '__main__':
UnprotectingSimplyProtectedWorksheet()
下载运行代码
下载**附加文件 (Aspose.Cells)**来自以下任何社交编码网站: