protection.py 1.2 KB

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