constants.py 4.5 KB

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