constants.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # Copyright (c) 2010-2024 openpyxl
  2. """Constants for fixed paths in a file and xml namespace urls."""
  3. MIN_ROW = 0
  4. MIN_COLUMN = 0
  5. MAX_COLUMN = 16384
  6. MAX_ROW = 1048576
  7. # constants
  8. PACKAGE_PROPS = 'docProps'
  9. PACKAGE_XL = 'xl'
  10. PACKAGE_RELS = '_rels'
  11. PACKAGE_THEME = PACKAGE_XL + '/' + 'theme'
  12. PACKAGE_WORKSHEETS = PACKAGE_XL + '/' + 'worksheets'
  13. PACKAGE_CHARTSHEETS = PACKAGE_XL + '/' + 'chartsheets'
  14. PACKAGE_DRAWINGS = PACKAGE_XL + '/' + 'drawings'
  15. PACKAGE_CHARTS = PACKAGE_XL + '/' + 'charts'
  16. PACKAGE_IMAGES = PACKAGE_XL + '/' + 'media'
  17. PACKAGE_WORKSHEET_RELS = PACKAGE_WORKSHEETS + '/' + '_rels'
  18. PACKAGE_CHARTSHEETS_RELS = PACKAGE_CHARTSHEETS + '/' + '_rels'
  19. PACKAGE_PIVOT_TABLE = PACKAGE_XL + '/' + 'pivotTables'
  20. PACKAGE_PIVOT_CACHE = PACKAGE_XL + '/' + 'pivotCache'
  21. ARC_CONTENT_TYPES = '[Content_Types].xml'
  22. ARC_ROOT_RELS = PACKAGE_RELS + '/.rels'
  23. ARC_WORKBOOK_RELS = PACKAGE_XL + '/' + PACKAGE_RELS + '/workbook.xml.rels'
  24. ARC_CORE = PACKAGE_PROPS + '/core.xml'
  25. ARC_APP = PACKAGE_PROPS + '/app.xml'
  26. ARC_CUSTOM = PACKAGE_PROPS + '/custom.xml'
  27. ARC_WORKBOOK = PACKAGE_XL + '/workbook.xml'
  28. ARC_STYLE = PACKAGE_XL + '/styles.xml'
  29. ARC_THEME = PACKAGE_THEME + '/theme1.xml'
  30. ARC_SHARED_STRINGS = PACKAGE_XL + '/sharedStrings.xml'
  31. ARC_CUSTOM_UI = 'customUI/customUI.xml'
  32. ## namespaces
  33. # XML
  34. XML_NS = "http://www.w3.org/XML/1998/namespace"
  35. # Dublin Core
  36. DCORE_NS = 'http://purl.org/dc/elements/1.1/'
  37. DCTERMS_NS = 'http://purl.org/dc/terms/'
  38. DCTERMS_PREFIX = 'dcterms'
  39. # Document
  40. DOC_NS = "http://schemas.openxmlformats.org/officeDocument/2006/"
  41. REL_NS = DOC_NS + "relationships"
  42. COMMENTS_NS = REL_NS + "/comments"
  43. IMAGE_NS = REL_NS + "/image"
  44. VML_NS = REL_NS + "/vmlDrawing"
  45. VTYPES_NS = DOC_NS + 'docPropsVTypes'
  46. XPROPS_NS = DOC_NS + 'extended-properties'
  47. CUSTPROPS_NS = DOC_NS + 'custom-properties'
  48. EXTERNAL_LINK_NS = REL_NS + "/externalLink"
  49. # CustomDocumentProperty FMTID:
  50. CPROPS_FMTID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"
  51. # Package
  52. PKG_NS = "http://schemas.openxmlformats.org/package/2006/"
  53. PKG_REL_NS = PKG_NS + "relationships"
  54. COREPROPS_NS = PKG_NS + 'metadata/core-properties'
  55. CONTYPES_NS = PKG_NS + 'content-types'
  56. XSI_NS = 'http://www.w3.org/2001/XMLSchema-instance'
  57. XML_NS = 'http://www.w3.org/XML/1998/namespace'
  58. SHEET_MAIN_NS = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'
  59. # Drawing
  60. CHART_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart"
  61. DRAWING_NS = "http://schemas.openxmlformats.org/drawingml/2006/main"
  62. SHEET_DRAWING_NS = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
  63. CHART_DRAWING_NS = "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing"
  64. CUSTOMUI_NS = 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility'
  65. NAMESPACES = {
  66. 'cp': COREPROPS_NS,
  67. 'dc': DCORE_NS,
  68. DCTERMS_PREFIX: DCTERMS_NS,
  69. 'dcmitype': 'http://purl.org/dc/dcmitype/',
  70. 'xsi': XSI_NS,
  71. 'vt': VTYPES_NS,
  72. 'xml': XML_NS,
  73. 'main': SHEET_MAIN_NS,
  74. 'cust': CUSTPROPS_NS,
  75. }
  76. ## Mime types
  77. WORKBOOK_MACRO = "application/vnd.ms-excel.%s.macroEnabled.main+xml"
  78. WORKBOOK = "application/vnd.openxmlformats-officedocument.spreadsheetml.%s.main+xml"
  79. SPREADSHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.%s+xml"
  80. SHARED_STRINGS = SPREADSHEET % "sharedStrings"
  81. EXTERNAL_LINK = SPREADSHEET % "externalLink"
  82. WORKSHEET_TYPE = SPREADSHEET % "worksheet"
  83. COMMENTS_TYPE = SPREADSHEET % "comments"
  84. STYLES_TYPE = SPREADSHEET % "styles"
  85. CHARTSHEET_TYPE = SPREADSHEET % "chartsheet"
  86. DRAWING_TYPE = "application/vnd.openxmlformats-officedocument.drawing+xml"
  87. CHART_TYPE = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
  88. CHARTSHAPE_TYPE = "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml"
  89. THEME_TYPE = "application/vnd.openxmlformats-officedocument.theme+xml"
  90. CPROPS_TYPE = "application/vnd.openxmlformats-officedocument.custom-properties+xml"
  91. XLTM = WORKBOOK_MACRO % 'template'
  92. XLSM = WORKBOOK_MACRO % 'sheet'
  93. XLTX = WORKBOOK % 'template'
  94. XLSX = WORKBOOK % 'sheet'
  95. # Extensions to the specification
  96. EXT_TYPES = {
  97. '{78C0D931-6437-407D-A8EE-F0AAD7539E65}': 'Conditional Formatting',
  98. '{CCE6A557-97BC-4B89-ADB6-D9C93CAAB3DF}': 'Data Validation',
  99. '{05C60535-1F16-4FD2-B633-F4F36F0B64E0}': 'Sparkline Group',
  100. '{A8765BA9-456A-4DAB-B4F3-ACF838C121DE}': 'Slicer List',
  101. '{FC87AEE6-9EDD-4A0A-B7FB-166176984837}': 'Protected Range',
  102. '{01252117-D84E-4E92-8308-4BE1C098FCBB}': 'Ignored Error',
  103. '{F7C9EE02-42E1-4005-9D12-6889AFFD525C}': 'Web Extension',
  104. '{3A4CF648-6AED-40f4-86FF-DC5316D8AED3}': 'Slicer List',
  105. '{7E03D99C-DC04-49d9-9315-930204A7B6E9}': 'Timeline Ref',
  106. }
  107. # Objects related to macros that we preserve
  108. CTRL = "application/vnd.ms-excel.controlproperties+xml"
  109. ACTIVEX = "application/vnd.ms-office.activeX+xml"
  110. VBA = "application/vnd.ms-office.vbaProject"