protection.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from __future__ import absolute_import
  2. import hashlib
  3. from openpyxl.descriptors import (Bool, Integer, String)
  4. from openpyxl.descriptors.excel import Base64Binary
  5. from openpyxl.descriptors.serialisable import Serialisable
  6. from openpyxl.worksheet.protection import (
  7. hash_password,
  8. _Protected
  9. )
  10. class ChartsheetProtection(Serialisable, _Protected):
  11. tagname = "sheetProtection"
  12. algorithmName = String(allow_none=True)
  13. hashValue = Base64Binary(allow_none=True)
  14. saltValue = Base64Binary(allow_none=True)
  15. spinCount = Integer(allow_none=True)
  16. content = Bool(allow_none=True)
  17. objects = Bool(allow_none=True)
  18. __attrs__ = ("content", "objects", "password", "hashValue", "spinCount", "saltValue", "algorithmName")
  19. def __init__(self,
  20. content=None,
  21. objects=None,
  22. hashValue=None,
  23. spinCount=None,
  24. saltValue=None,
  25. algorithmName=None,
  26. password=None,
  27. ):
  28. self.content = content
  29. self.objects = objects
  30. self.hashValue = hashValue
  31. self.spinCount = spinCount
  32. self.saltValue = saltValue
  33. self.algorithmName = algorithmName
  34. if password is not None:
  35. self.password = password