rubyXL 2.5.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rubyXL.rb +4 -1
  4. data/lib/rubyXL/objects/calculation_chain.rb +4 -6
  5. data/lib/rubyXL/objects/chartsheet.rb +16 -13
  6. data/lib/rubyXL/objects/color.rb +1 -1
  7. data/lib/rubyXL/objects/comments.rb +46 -0
  8. data/lib/rubyXL/objects/content_types.rb +17 -55
  9. data/lib/rubyXL/objects/document_properties.rb +13 -15
  10. data/lib/rubyXL/objects/filters.rb +1 -1
  11. data/lib/rubyXL/objects/ooxml_object.rb +24 -11
  12. data/lib/rubyXL/objects/reference.rb +1 -1
  13. data/lib/rubyXL/objects/relationships.rb +147 -31
  14. data/lib/rubyXL/objects/root.rb +57 -0
  15. data/lib/rubyXL/objects/shared_strings.rb +4 -5
  16. data/lib/rubyXL/objects/sheet_data.rb +8 -2
  17. data/lib/rubyXL/objects/storage.rb +169 -0
  18. data/lib/rubyXL/objects/stylesheet.rb +4 -5
  19. data/lib/rubyXL/objects/text.rb +3 -3
  20. data/lib/rubyXL/objects/theme.rb +4 -6
  21. data/lib/rubyXL/objects/workbook.rb +50 -22
  22. data/lib/rubyXL/objects/worksheet.rb +36 -12
  23. data/lib/rubyXL/parser.rb +23 -97
  24. data/lib/rubyXL/workbook.rb +29 -41
  25. data/lib/rubyXL/worksheet.rb +3 -0
  26. data/rdoc/README_rdoc.html +1 -1
  27. data/rdoc/RubyXL.html +1 -1
  28. data/rdoc/RubyXL/AExtension.html +1 -1
  29. data/rdoc/RubyXL/AExtensionStorageArea.html +1 -1
  30. data/rdoc/RubyXL/AdjustHandleList.html +1 -1
  31. data/rdoc/RubyXL/Alignment.html +1 -1
  32. data/rdoc/RubyXL/AlternateContent.html +1 -1
  33. data/rdoc/RubyXL/Authors.html +105 -0
  34. data/rdoc/RubyXL/AutoFilter.html +1 -1
  35. data/rdoc/RubyXL/AutoFilterColumn.html +1 -1
  36. data/rdoc/RubyXL/BinaryImageFile.html +105 -0
  37. data/rdoc/RubyXL/BodyProperties.html +1 -1
  38. data/rdoc/RubyXL/BooleanNode.html +1 -1
  39. data/rdoc/RubyXL/BooleanValue.html +1 -1
  40. data/rdoc/RubyXL/Border.html +1 -1
  41. data/rdoc/RubyXL/BorderEdge.html +1 -1
  42. data/rdoc/RubyXL/Borders.html +1 -1
  43. data/rdoc/RubyXL/Break.html +1 -1
  44. data/rdoc/RubyXL/BreakList.html +1 -1
  45. data/rdoc/RubyXL/CT_AdjPoint2D.html +1 -1
  46. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +1 -1
  47. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +1 -1
  48. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +1 -1
  49. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +1 -1
  50. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +1 -1
  51. data/rdoc/RubyXL/CT_Backdrop.html +1 -1
  52. data/rdoc/RubyXL/CT_Bevel.html +1 -1
  53. data/rdoc/RubyXL/CT_BiLevelEffect.html +1 -1
  54. data/rdoc/RubyXL/CT_BlendEffect.html +1 -1
  55. data/rdoc/RubyXL/CT_Blip.html +1 -1
  56. data/rdoc/RubyXL/CT_BlipFillProperties.html +1 -1
  57. data/rdoc/RubyXL/CT_BlurEffect.html +1 -1
  58. data/rdoc/RubyXL/CT_Camera.html +1 -1
  59. data/rdoc/RubyXL/CT_Color.html +1 -1
  60. data/rdoc/RubyXL/CT_ColorChangeEffect.html +1 -1
  61. data/rdoc/RubyXL/CT_ColorMapping.html +1 -1
  62. data/rdoc/RubyXL/CT_ColorScheme.html +1 -1
  63. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +1 -1
  64. data/rdoc/RubyXL/CT_ConnectionSite.html +1 -1
  65. data/rdoc/RubyXL/CT_ConnectionSiteList.html +1 -1
  66. data/rdoc/RubyXL/CT_DashStop.html +1 -1
  67. data/rdoc/RubyXL/CT_DashStopList.html +1 -1
  68. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +1 -1
  69. data/rdoc/RubyXL/CT_DuotoneEffect.html +1 -1
  70. data/rdoc/RubyXL/CT_EffectContainer.html +1 -1
  71. data/rdoc/RubyXL/CT_EffectList.html +1 -1
  72. data/rdoc/RubyXL/CT_EffectReference.html +1 -1
  73. data/rdoc/RubyXL/CT_EffectStyleItem.html +1 -1
  74. data/rdoc/RubyXL/CT_EffectStyleList.html +1 -1
  75. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +1 -1
  76. data/rdoc/RubyXL/CT_FillEffect.html +1 -1
  77. data/rdoc/RubyXL/CT_FillOverlayEffect.html +1 -1
  78. data/rdoc/RubyXL/CT_FillStyleList.html +1 -1
  79. data/rdoc/RubyXL/CT_FlatText.html +1 -1
  80. data/rdoc/RubyXL/CT_FontCollection.html +1 -1
  81. data/rdoc/RubyXL/CT_FontReference.html +1 -1
  82. data/rdoc/RubyXL/CT_GeomGuideList.html +1 -1
  83. data/rdoc/RubyXL/CT_GlowEffect.html +1 -1
  84. data/rdoc/RubyXL/CT_GradientFillProperties.html +1 -1
  85. data/rdoc/RubyXL/CT_GradientStop.html +1 -1
  86. data/rdoc/RubyXL/CT_GradientStopList.html +1 -1
  87. data/rdoc/RubyXL/CT_HSLEffect.html +1 -1
  88. data/rdoc/RubyXL/CT_HslColor.html +1 -1
  89. data/rdoc/RubyXL/CT_Hyperlink.html +1 -1
  90. data/rdoc/RubyXL/CT_InnerShadowEffect.html +1 -1
  91. data/rdoc/RubyXL/CT_LightRig.html +1 -1
  92. data/rdoc/RubyXL/CT_LineEndProperties.html +1 -1
  93. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +1 -1
  94. data/rdoc/RubyXL/CT_LineProperties.html +1 -1
  95. data/rdoc/RubyXL/CT_LineStyleList.html +1 -1
  96. data/rdoc/RubyXL/CT_LinearShadeProperties.html +1 -1
  97. data/rdoc/RubyXL/CT_LuminanceEffect.html +1 -1
  98. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +1 -1
  99. data/rdoc/RubyXL/CT_OuterShadowEffect.html +1 -1
  100. data/rdoc/RubyXL/CT_Path2D.html +1 -1
  101. data/rdoc/RubyXL/CT_Path2DArcTo.html +1 -1
  102. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +1 -1
  103. data/rdoc/RubyXL/CT_Path2DList.html +1 -1
  104. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +1 -1
  105. data/rdoc/RubyXL/CT_Path2DTo.html +1 -1
  106. data/rdoc/RubyXL/CT_PathShadeProperties.html +1 -1
  107. data/rdoc/RubyXL/CT_PatternFillProperties.html +1 -1
  108. data/rdoc/RubyXL/CT_Point3D.html +1 -1
  109. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +1 -1
  110. data/rdoc/RubyXL/CT_PresetColor.html +1 -1
  111. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +1 -1
  112. data/rdoc/RubyXL/CT_PresetShadowEffect.html +1 -1
  113. data/rdoc/RubyXL/CT_PresetTextShape.html +1 -1
  114. data/rdoc/RubyXL/CT_ReflectionEffect.html +1 -1
  115. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +1 -1
  116. data/rdoc/RubyXL/CT_RelativeRect.html +1 -1
  117. data/rdoc/RubyXL/CT_SRgbColor.html +1 -1
  118. data/rdoc/RubyXL/CT_ScRgbColor.html +1 -1
  119. data/rdoc/RubyXL/CT_Scene3D.html +1 -1
  120. data/rdoc/RubyXL/CT_SchemeColor.html +1 -1
  121. data/rdoc/RubyXL/CT_Shape3D.html +1 -1
  122. data/rdoc/RubyXL/CT_ShapeStyle.html +1 -1
  123. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +1 -1
  124. data/rdoc/RubyXL/CT_SphereCoords.html +1 -1
  125. data/rdoc/RubyXL/CT_StretchInfoProperties.html +1 -1
  126. data/rdoc/RubyXL/CT_StyleMatrix.html +1 -1
  127. data/rdoc/RubyXL/CT_StyleMatrixReference.html +1 -1
  128. data/rdoc/RubyXL/CT_SupplementalFont.html +1 -1
  129. data/rdoc/RubyXL/CT_SystemColor.html +1 -1
  130. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +1 -1
  131. data/rdoc/RubyXL/CT_TextBlipBullet.html +1 -1
  132. data/rdoc/RubyXL/CT_TextCharBullet.html +1 -1
  133. data/rdoc/RubyXL/CT_TextCharacterProperties.html +1 -1
  134. data/rdoc/RubyXL/CT_TextFont.html +1 -1
  135. data/rdoc/RubyXL/CT_TextListStyle.html +1 -1
  136. data/rdoc/RubyXL/CT_TextNormalAutofit.html +1 -1
  137. data/rdoc/RubyXL/CT_TextParagraphProperties.html +1 -1
  138. data/rdoc/RubyXL/CT_TextSpacing.html +1 -1
  139. data/rdoc/RubyXL/CT_TextTabStop.html +1 -1
  140. data/rdoc/RubyXL/CT_TextTabStopList.html +1 -1
  141. data/rdoc/RubyXL/CT_TileInfoProperties.html +1 -1
  142. data/rdoc/RubyXL/CT_TintEffect.html +1 -1
  143. data/rdoc/RubyXL/CT_Transform2D.html +1 -1
  144. data/rdoc/RubyXL/CT_TransformEffect.html +1 -1
  145. data/rdoc/RubyXL/CT_Vector3D.html +1 -1
  146. data/rdoc/RubyXL/CT_XYAdjustHandle.html +1 -1
  147. data/rdoc/RubyXL/CalculationChain.html +26 -42
  148. data/rdoc/RubyXL/CalculationChainCell.html +1 -1
  149. data/rdoc/RubyXL/CalculationProperties.html +1 -1
  150. data/rdoc/RubyXL/Cell.html +13 -13
  151. data/rdoc/RubyXL/CellSmartTag.html +1 -1
  152. data/rdoc/RubyXL/CellSmartTagProperty.html +1 -1
  153. data/rdoc/RubyXL/CellSmartTags.html +1 -1
  154. data/rdoc/RubyXL/CellStyle.html +1 -1
  155. data/rdoc/RubyXL/CellStyleXFs.html +1 -1
  156. data/rdoc/RubyXL/CellStyles.html +1 -1
  157. data/rdoc/RubyXL/CellValue.html +53 -1
  158. data/rdoc/RubyXL/CellWatch.html +1 -1
  159. data/rdoc/RubyXL/CellWatches.html +1 -1
  160. data/rdoc/RubyXL/CellXFs.html +1 -1
  161. data/rdoc/RubyXL/ChartColorsFile.html +105 -0
  162. data/rdoc/RubyXL/ChartFile.html +105 -0
  163. data/rdoc/RubyXL/ChartRelationshipsFile.html +105 -0
  164. data/rdoc/RubyXL/ChartStyleFile.html +105 -0
  165. data/rdoc/RubyXL/ChartUserShapesFile.html +105 -0
  166. data/rdoc/RubyXL/Chartsheet.html +1 -1
  167. data/rdoc/RubyXL/ChartsheetPageSetup.html +1 -1
  168. data/rdoc/RubyXL/ChartsheetProperties.html +1 -1
  169. data/rdoc/RubyXL/ChartsheetProtection.html +1 -1
  170. data/rdoc/RubyXL/ChartsheetView.html +1 -1
  171. data/rdoc/RubyXL/ChartsheetViews.html +1 -1
  172. data/rdoc/RubyXL/Color.html +2 -2
  173. data/rdoc/RubyXL/ColorFilter.html +1 -1
  174. data/rdoc/RubyXL/ColorScale.html +1 -1
  175. data/rdoc/RubyXL/ColorSet.html +1 -1
  176. data/rdoc/RubyXL/Colors.html +1 -1
  177. data/rdoc/RubyXL/ColumnRange.html +1 -1
  178. data/rdoc/RubyXL/ColumnRanges.html +1 -1
  179. data/rdoc/RubyXL/Comment.html +108 -0
  180. data/rdoc/RubyXL/CommentList.html +105 -0
  181. data/rdoc/RubyXL/{CoreProperties.html → CommentsFile.html} +4 -4
  182. data/rdoc/RubyXL/ConditionalFormatValue.html +1 -1
  183. data/rdoc/RubyXL/ConditionalFormatting.html +1 -1
  184. data/rdoc/RubyXL/ConditionalFormattingRule.html +1 -1
  185. data/rdoc/RubyXL/ContentTypeDefault.html +1 -1
  186. data/rdoc/RubyXL/ContentTypeOverride.html +1 -1
  187. data/rdoc/RubyXL/ContentTypes.html +87 -63
  188. data/rdoc/RubyXL/ControlPropertiesFile.html +105 -0
  189. data/rdoc/RubyXL/CorePropertiesFile.html +105 -0
  190. data/rdoc/RubyXL/CustomColor.html +1 -1
  191. data/rdoc/RubyXL/CustomColorList.html +1 -1
  192. data/rdoc/RubyXL/CustomFilter.html +1 -1
  193. data/rdoc/RubyXL/CustomFilters.html +1 -1
  194. data/rdoc/RubyXL/CustomGeometry.html +1 -1
  195. data/rdoc/RubyXL/CustomProperties.html +1 -1
  196. data/rdoc/RubyXL/CustomPropertiesFile.html +105 -0
  197. data/rdoc/RubyXL/CustomProperty.html +1 -1
  198. data/rdoc/RubyXL/CustomSheetView.html +1 -1
  199. data/rdoc/RubyXL/CustomSheetViews.html +1 -1
  200. data/rdoc/RubyXL/CustomWorkbookView.html +1 -1
  201. data/rdoc/RubyXL/CustomWorkbookViews.html +1 -1
  202. data/rdoc/RubyXL/CustomXMLFile.html +105 -0
  203. data/rdoc/RubyXL/DXF.html +1 -1
  204. data/rdoc/RubyXL/DXFs.html +1 -1
  205. data/rdoc/RubyXL/DataBar.html +1 -1
  206. data/rdoc/RubyXL/DataConsolidate.html +1 -1
  207. data/rdoc/RubyXL/DataConsolidationReference.html +1 -1
  208. data/rdoc/RubyXL/DataConsolidationReferences.html +1 -1
  209. data/rdoc/RubyXL/DataType.html +1 -1
  210. data/rdoc/RubyXL/DataValidation.html +1 -1
  211. data/rdoc/RubyXL/DataValidations.html +1 -1
  212. data/rdoc/RubyXL/DateGroupItem.html +1 -1
  213. data/rdoc/RubyXL/DefinedName.html +1 -1
  214. data/rdoc/RubyXL/DefinedNames.html +1 -1
  215. data/rdoc/RubyXL/{DocumentProperties.html → DocumentPropertiesFile.html} +59 -83
  216. data/rdoc/RubyXL/DrawingFile.html +225 -0
  217. data/rdoc/RubyXL/DrawingRelationshipsFile.html +105 -0
  218. data/rdoc/RubyXL/DynamicFilter.html +1 -1
  219. data/rdoc/RubyXL/EmbeddedControl.html +1 -1
  220. data/rdoc/RubyXL/EmbeddedControls.html +1 -1
  221. data/rdoc/RubyXL/Extension.html +1 -1
  222. data/rdoc/RubyXL/ExtensionStorageArea.html +1 -1
  223. data/rdoc/RubyXL/Extents.html +1 -1
  224. data/rdoc/RubyXL/ExternalLinksFile.html +105 -0
  225. data/rdoc/RubyXL/ExternalReference.html +1 -1
  226. data/rdoc/RubyXL/ExternalReferences.html +1 -1
  227. data/rdoc/RubyXL/ExtraColorSchemeList.html +1 -1
  228. data/rdoc/RubyXL/FieldItem.html +1 -1
  229. data/rdoc/RubyXL/FileRecoveryProperties.html +1 -1
  230. data/rdoc/RubyXL/FileSharing.html +1 -1
  231. data/rdoc/RubyXL/FileVersion.html +1 -1
  232. data/rdoc/RubyXL/Fill.html +1 -1
  233. data/rdoc/RubyXL/Fills.html +1 -1
  234. data/rdoc/RubyXL/FilterContainer.html +1 -1
  235. data/rdoc/RubyXL/FloatNode.html +1 -1
  236. data/rdoc/RubyXL/FloatValue.html +1 -1
  237. data/rdoc/RubyXL/Font.html +1 -1
  238. data/rdoc/RubyXL/FontScheme.html +1 -1
  239. data/rdoc/RubyXL/Fonts.html +1 -1
  240. data/rdoc/RubyXL/Formula.html +1 -1
  241. data/rdoc/RubyXL/FunctionGroup.html +1 -1
  242. data/rdoc/RubyXL/FunctionGroups.html +1 -1
  243. data/rdoc/RubyXL/GenericStorageObject.html +352 -0
  244. data/rdoc/RubyXL/GradientFill.html +1 -1
  245. data/rdoc/RubyXL/HeaderFooterSettings.html +1 -1
  246. data/rdoc/RubyXL/Hyperlink.html +1 -1
  247. data/rdoc/RubyXL/HyperlinkRelFile.html +105 -0
  248. data/rdoc/RubyXL/Hyperlinks.html +1 -1
  249. data/rdoc/RubyXL/IconFilter.html +1 -1
  250. data/rdoc/RubyXL/IconSet.html +1 -1
  251. data/rdoc/RubyXL/IgnoredError.html +1 -1
  252. data/rdoc/RubyXL/IgnoredErrors.html +1 -1
  253. data/rdoc/RubyXL/IndexedColors.html +1 -1
  254. data/rdoc/RubyXL/InputCells.html +1 -1
  255. data/rdoc/RubyXL/IntegerNode.html +1 -1
  256. data/rdoc/RubyXL/IntegerValue.html +1 -1
  257. data/rdoc/RubyXL/LegacyCell.html +1 -1
  258. data/rdoc/RubyXL/LegacyWorkbook.html +48 -343
  259. data/rdoc/RubyXL/LegacyWorksheet.html +83 -80
  260. data/rdoc/RubyXL/MRUColors.html +1 -1
  261. data/rdoc/RubyXL/MacrosFile.html +105 -0
  262. data/rdoc/RubyXL/MergedCell.html +1 -1
  263. data/rdoc/RubyXL/MergedCells.html +1 -1
  264. data/rdoc/RubyXL/NumFmt.html +1 -1
  265. data/rdoc/RubyXL/NumberFormat.html +1 -1
  266. data/rdoc/RubyXL/NumberFormats.html +1 -1
  267. data/rdoc/RubyXL/OLEObject.html +1 -1
  268. data/rdoc/RubyXL/OLEObjects.html +1 -1
  269. data/rdoc/RubyXL/OLESize.html +1 -1
  270. data/rdoc/RubyXL/OOXMLContainerObject.html +1 -1
  271. data/rdoc/RubyXL/OOXMLObject.html +1 -1
  272. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +3 -3
  273. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +1 -1
  274. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +283 -20
  275. data/rdoc/RubyXL/OOXMLTopLevelObject.html +1 -1
  276. data/rdoc/RubyXL/Offset.html +1 -1
  277. data/rdoc/RubyXL/OutlineProperties.html +1 -1
  278. data/rdoc/RubyXL/PageMargins.html +1 -1
  279. data/rdoc/RubyXL/PageSetup.html +1 -1
  280. data/rdoc/RubyXL/PageSetupProperties.html +1 -1
  281. data/rdoc/RubyXL/Pane.html +1 -1
  282. data/rdoc/RubyXL/Parser.html +35 -139
  283. data/rdoc/RubyXL/PatternFill.html +1 -1
  284. data/rdoc/RubyXL/PhoneticProperties.html +1 -1
  285. data/rdoc/RubyXL/PhoneticRun.html +1 -1
  286. data/rdoc/RubyXL/PivotArea.html +1 -1
  287. data/rdoc/RubyXL/PivotCache.html +1 -1
  288. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +105 -0
  289. data/rdoc/RubyXL/PivotCaches.html +1 -1
  290. data/rdoc/RubyXL/PivotReference.html +1 -1
  291. data/rdoc/RubyXL/PivotReferences.html +1 -1
  292. data/rdoc/RubyXL/PivotTableFile.html +105 -0
  293. data/rdoc/RubyXL/PivotTableSelection.html +1 -1
  294. data/rdoc/RubyXL/PresetGeometry.html +1 -1
  295. data/rdoc/RubyXL/PrintOptions.html +1 -1
  296. data/rdoc/RubyXL/PrinterSettingsFile.html +119 -0
  297. data/rdoc/RubyXL/ProtectedRange.html +1 -1
  298. data/rdoc/RubyXL/ProtectedRanges.html +1 -1
  299. data/rdoc/RubyXL/Protection.html +1 -1
  300. data/rdoc/RubyXL/RID.html +1 -1
  301. data/rdoc/RubyXL/RawOOXML.html +1 -1
  302. data/rdoc/RubyXL/Reference.html +2 -2
  303. data/rdoc/RubyXL/Relationship.html +1 -1
  304. data/rdoc/RubyXL/RelationshipSupport.html +98 -0
  305. data/rdoc/RubyXL/RichText.html +1 -1
  306. data/rdoc/RubyXL/RichTextRun.html +1 -1
  307. data/rdoc/RubyXL/RootRelationships.html +1 -1
  308. data/rdoc/RubyXL/Row.html +1 -1
  309. data/rdoc/RubyXL/RunProperties.html +1 -1
  310. data/rdoc/RubyXL/Scenario.html +1 -1
  311. data/rdoc/RubyXL/Scenarios.html +1 -1
  312. data/rdoc/RubyXL/Selection.html +1 -1
  313. data/rdoc/RubyXL/ShapeGuide.html +1 -1
  314. data/rdoc/RubyXL/ShapeTextRectangle.html +1 -1
  315. data/rdoc/RubyXL/SharedStringsTable.html +61 -77
  316. data/rdoc/RubyXL/Sheet.html +1 -1
  317. data/rdoc/RubyXL/SheetCalculationProperties.html +1 -1
  318. data/rdoc/RubyXL/SheetData.html +1 -1
  319. data/rdoc/RubyXL/SheetRelationshipsFile.html +105 -0
  320. data/rdoc/RubyXL/Sheets.html +1 -1
  321. data/rdoc/RubyXL/SlicerCacheFile.html +105 -0
  322. data/rdoc/RubyXL/SlicerFile.html +105 -0
  323. data/rdoc/RubyXL/SmartTagProperties.html +1 -1
  324. data/rdoc/RubyXL/SmartTagType.html +1 -1
  325. data/rdoc/RubyXL/SmartTagTypes.html +1 -1
  326. data/rdoc/RubyXL/SmartTags.html +1 -1
  327. data/rdoc/RubyXL/SortCondition.html +1 -1
  328. data/rdoc/RubyXL/SortState.html +1 -1
  329. data/rdoc/RubyXL/Sqref.html +1 -1
  330. data/rdoc/RubyXL/Stop.html +1 -1
  331. data/rdoc/RubyXL/StringNode.html +1 -1
  332. data/rdoc/RubyXL/StringNodeW3C.html +1 -1
  333. data/rdoc/RubyXL/StringValue.html +1 -1
  334. data/rdoc/RubyXL/Stylesheet.html +1 -1
  335. data/rdoc/RubyXL/TableFile.html +105 -0
  336. data/rdoc/RubyXL/TableParts.html +1 -1
  337. data/rdoc/RubyXL/TableStyle.html +1 -1
  338. data/rdoc/RubyXL/TableStyles.html +1 -1
  339. data/rdoc/RubyXL/Text.html +2 -2
  340. data/rdoc/RubyXL/Theme.html +1 -1
  341. data/rdoc/RubyXL/ThemeElements.html +1 -1
  342. data/rdoc/RubyXL/ThumbnailFile.html +105 -0
  343. data/rdoc/RubyXL/Top10.html +1 -1
  344. data/rdoc/RubyXL/VMLDrawingFile.html +105 -0
  345. data/rdoc/RubyXL/Variant.html +1 -1
  346. data/rdoc/RubyXL/Vector.html +1 -1
  347. data/rdoc/RubyXL/VectorValue.html +1 -1
  348. data/rdoc/RubyXL/VisualProperties.html +1 -1
  349. data/rdoc/RubyXL/WebPublishObject.html +1 -1
  350. data/rdoc/RubyXL/WebPublishObjects.html +1 -1
  351. data/rdoc/RubyXL/WebPublishingItem.html +1 -1
  352. data/rdoc/RubyXL/WebPublishingItems.html +1 -1
  353. data/rdoc/RubyXL/WebPublishingProperties.html +1 -1
  354. data/rdoc/RubyXL/Workbook.html +1 -1
  355. data/rdoc/RubyXL/WorkbookProperties.html +1 -1
  356. data/rdoc/RubyXL/WorkbookProtection.html +1 -1
  357. data/rdoc/RubyXL/WorkbookRelationships.html +1 -1
  358. data/rdoc/RubyXL/WorkbookRoot.html +449 -0
  359. data/rdoc/RubyXL/WorkbookView.html +1 -1
  360. data/rdoc/RubyXL/WorkbookViews.html +1 -1
  361. data/rdoc/RubyXL/Worksheet.html +1 -1
  362. data/rdoc/RubyXL/WorksheetDimensions.html +1 -1
  363. data/rdoc/RubyXL/WorksheetFormatProperties.html +1 -1
  364. data/rdoc/RubyXL/WorksheetProperties.html +1 -1
  365. data/rdoc/RubyXL/WorksheetProtection.html +1 -1
  366. data/rdoc/RubyXL/WorksheetView.html +1 -1
  367. data/rdoc/RubyXL/WorksheetViews.html +1 -1
  368. data/rdoc/RubyXL/XF.html +1 -1
  369. data/rdoc/created.rid +30 -28
  370. data/rdoc/index.html +12 -4
  371. data/rdoc/js/search_index.js +1 -1
  372. data/rdoc/table_of_contents.html +160 -98
  373. data/rubyXL.gemspec +38 -7
  374. data/test/test_parse_write.rb +4 -4
  375. metadata +37 -6
  376. data/lib/rubyXL/generic_storage.rb +0 -42
  377. data/rdoc/RubyXL/GenericStorage.html +0 -346
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 794a18bdbb32248109cbf8db6c6980baa9554b94
4
- data.tar.gz: 4d719ab25167db598f866854da7828b61e849b3b
3
+ metadata.gz: 5a09e59d3e1ba47212acd8cd808c8863d85016d7
4
+ data.tar.gz: f4ad0faaf011c66154a6d97f84c16ed255ddfd13
5
5
  SHA512:
6
- metadata.gz: e78a5c5c76d25bbc1a0a8fa59ca07fe949a0b4584e22bf253894399d691f0fbc50518a9ec06740050fd9d01859c7474ac9594387dac7c18c7f1de022cfb7a644
7
- data.tar.gz: 3096460f2cdd9f40f6385eaedcf59bcd6902ed24f46c1de7a16d8fac104228296b7cec75869639f0252b4dde959b63ceacb5bb0da7125abe04511346d80f27b9
6
+ metadata.gz: 9553c04829bf02bc5918341deeb9a535086bc80cbc0d64ce964fcad89cbfd5f925f4dda11e72aad5d015d3f82dbaa0ebb26b650da2327de15dcd57c4fb00e1c3
7
+ data.tar.gz: a0f90671f4710d6f1a5589e6d9462b171ed84873bdd5427c63d8daa24a6c1c845178f54775b7508bde5da07a3d487844e9f80de19081b1a3adb8209520f083b1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.5.7
1
+ 3.0.0
data/lib/rubyXL.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubyXL/objects/relationships'
1
2
  require 'rubyXL/workbook'
2
3
  require 'rubyXL/worksheet'
3
4
  require 'rubyXL/cell'
@@ -10,9 +11,11 @@ require 'rubyXL/objects/chartsheet'
10
11
  require 'rubyXL/objects/calculation_chain'
11
12
  require 'rubyXL/objects/content_types'
12
13
  require 'rubyXL/objects/theme'
14
+ require 'rubyXL/objects/comments'
15
+ require 'rubyXL/objects/root'
13
16
  require 'rubyXL/objects/workbook'
14
17
  require 'rubyXL/objects/document_properties'
15
- require 'rubyXL/objects/relationships'
18
+ require 'rubyXL/objects/storage'
16
19
  require 'rubyXL/parser'
17
20
 
18
21
  module RubyXL
@@ -15,19 +15,17 @@ module RubyXL
15
15
 
16
16
  # http://www.schemacentral.com/sc/ooxml/e-ssml_calcChain.html
17
17
  class CalculationChain < OOXMLTopLevelObject
18
+ CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml'
19
+ REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain'
20
+
18
21
  define_child_node(RubyXL::CalculationChainCell, :collection => true, :accessor => :cells)
19
22
  define_child_node(RubyXL::ExtensionStorageArea)
20
23
 
21
24
  define_element_name 'calcChain'
22
25
  set_namespaces('http://schemas.openxmlformats.org/spreadsheetml/2006/main' => '')
23
26
 
24
- def self.xlsx_path
27
+ def xlsx_path
25
28
  File.join('xl', 'calcChain.xml')
26
29
  end
27
-
28
- def self.content_type
29
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml'
30
- end
31
-
32
30
  end
33
31
  end
@@ -57,6 +57,14 @@ module RubyXL
57
57
 
58
58
  # http://www.schemacentral.com/sc/ooxml/e-ssml_chartsheet.html
59
59
  class Chartsheet < OOXMLTopLevelObject
60
+ CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml'
61
+ REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet'
62
+
63
+ include RubyXL::RelationshipSupport
64
+
65
+ attr_accessor :state, :rels
66
+ attr_accessor :workbook, :sheet_name, :sheet_id
67
+
60
68
  define_child_node(RubyXL::ChartsheetProperties)
61
69
  define_child_node(RubyXL::ChartsheetViews)
62
70
  define_child_node(RubyXL::ChartsheetProtection)
@@ -74,26 +82,21 @@ module RubyXL
74
82
  set_namespaces('http://schemas.openxmlformats.org/spreadsheetml/2006/main' => '',
75
83
  'http://schemas.openxmlformats.org/officeDocument/2006/relationships' => 'r')
76
84
 
77
- attr_accessor :state
78
-
79
- def sheet_index
80
- @workbook.worksheets.select{ |sheet| sheet.is_a?(self.class) }.index{ |sheet| sheet.equal?(self) }
81
- end
82
-
83
85
  def xlsx_path
84
- File.join('xl', 'chartsheets', "sheet#{sheet_index + 1}.xml")
86
+ File.join('xl', 'chartsheets', "sheet#{file_index}.xml")
85
87
  end
86
88
 
87
- def rel_type
88
- 'chartsheet'
89
+ def relationship_file_class
90
+ RubyXL::SheetRelationshipsFile
89
91
  end
90
92
 
91
- def self.content_type
92
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml'
93
+ def attach_relationship(rid, rf)
94
+ case rf
95
+ when RubyXL::DrawingFile then store_relationship(rf) # TODO
96
+ else store_relationship(rf, :unknown)
97
+ end
93
98
  end
94
99
 
95
- attr_accessor :workbook, :sheet_name, :sheet_id
96
-
97
100
  end
98
101
 
99
102
  end
@@ -13,7 +13,7 @@ module RubyXL
13
13
 
14
14
  #validates hex color code, no '#' allowed
15
15
  def self.validate_color(color)
16
- if color =~ /^([a-f]|[A-F]|[0-9]){6}$/
16
+ if color =~ /\A([a-f]|[A-F]|[0-9]){6}\Z/
17
17
  return true
18
18
  else
19
19
  raise 'invalid color'
@@ -0,0 +1,46 @@
1
+ require 'rubyXL/objects/ooxml_object'
2
+ require 'rubyXL/objects/extensions'
3
+
4
+ module RubyXL
5
+
6
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_comment-1.html
7
+ class Comment < OOXMLObject
8
+ define_child_node(RubyXL::RichText, :node_name => 'text')
9
+ define_attribute(:ref, :ref, :required => true)
10
+ define_attribute(:authorId, :int, :required => true)
11
+ define_attribute(:guid, :string)
12
+ define_element_name 'comment'
13
+ end
14
+
15
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_authors-1.html
16
+ class CommentList < OOXMLContainerObject
17
+ define_child_node(RubyXL::Comment, :collection => :true)
18
+ define_element_name 'commentList'
19
+ end
20
+
21
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_authors-1.html
22
+ class Authors < OOXMLContainerObject
23
+ define_child_node(RubyXL::StringNode, :node_name => :author, :collection => :true)
24
+ define_element_name 'authors'
25
+ end
26
+
27
+ # http://www.schemacentral.com/sc/ooxml/e-ssml_comments.html
28
+ class CommentsFile < OOXMLTopLevelObject
29
+ CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
30
+ REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments'
31
+
32
+ define_child_node(RubyXL::Authors)
33
+ define_child_node(RubyXL::CommentList)
34
+ define_child_node(RubyXL::ExtensionStorageArea)
35
+ define_element_name 'comments'
36
+ set_namespaces('http://schemas.openxmlformats.org/spreadsheetml/2006/main' => '')
37
+
38
+ attr_accessor :workbook
39
+
40
+ def xlsx_path
41
+ File.join('xl', "comments#{file_index}.xml")
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -15,7 +15,7 @@ module RubyXL
15
15
  end
16
16
 
17
17
  class ContentTypes < OOXMLTopLevelObject
18
- attr_accessor :workbook
18
+ attr_accessor :owner
19
19
 
20
20
  define_child_node(RubyXL::ContentTypeDefault, :collection => true, :accessor => :defaults)
21
21
  define_child_node(RubyXL::ContentTypeOverride, :collection => true, :accessor => :overrides)
@@ -27,13 +27,22 @@ module RubyXL
27
27
  '[Content_Types].xml'
28
28
  end
29
29
 
30
- def generate_override(obj)
31
- obj && RubyXL::ContentTypeOverride.new(:part_name => "/#{obj.xlsx_path}", :content_type => obj.class.content_type)
30
+ def xlsx_path
31
+ self.class.xlsx_path
32
+ end
33
+
34
+ def self.save_order
35
+ 999 # Must be saved last, so it has time to accumulate overrides from all others.
36
+ end
37
+
38
+ def add_override(obj)
39
+ return unless obj.class.const_defined?(:CONTENT_TYPE)
40
+ overrides << RubyXL::ContentTypeOverride.new(:part_name => "/#{obj.xlsx_path}", :content_type => obj.class::CONTENT_TYPE)
32
41
  end
33
42
 
34
43
  def before_write_xml
35
44
  self.defaults = []
36
- unless @workbook.printer_settings.empty?
45
+ if owner.rels_hash[RubyXL::PrinterSettingsFile] then
37
46
  defaults << RubyXL::ContentTypeDefault.new(:extension => 'bin',
38
47
  :content_type => 'application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings')
39
48
  end
@@ -45,58 +54,11 @@ module RubyXL
45
54
  :content_type => 'application/xml' )
46
55
 
47
56
  # TODO: Need to only write these types when respective content is actually present.
48
- defaults << RubyXL::ContentTypeDefault.new(:extension => 'jpeg', :content_type => 'image/jpeg' )
49
- defaults << RubyXL::ContentTypeDefault.new(:extension => 'png', :content_type => 'image/png' )
50
-
51
- self.overrides = []
52
- overrides << generate_override(workbook)
53
- workbook.worksheets.each { |sheet| overrides << generate_override(sheet) }
54
- overrides << generate_override(workbook.stylesheet)
55
- overrides << generate_override(workbook.document_properties)
56
- overrides << generate_override(workbook.core_properties)
57
- overrides << generate_override(workbook.shared_strings_container) if workbook.shared_strings_container && !workbook.shared_strings_container.empty?
58
- overrides << generate_override(workbook.calculation_chain)
59
- overrides << generate_override(workbook.theme)
60
-
61
- workbook.charts.each_pair { |k, v|
62
- case k
63
- when /^chart\d*.xml$/ then
64
- overrides << RubyXL::ContentTypeOverride.new(:part_name => "/#{@workbook.charts.local_dir_path}/#{k}",
65
- :content_type => 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml')
66
- when /^style\d*.xml$/ then
67
- overrides << RubyXL::ContentTypeOverride.new(:part_name => "/#{@workbook.charts.local_dir_path}/#{k}",
68
- :content_type => 'application/vnd.ms-office.chartstyle+xml')
69
- when /^colors\d*.xml$/ then
70
- overrides << RubyXL::ContentTypeOverride.new(:part_name => "/#{@workbook.charts.local_dir_path}/#{k}",
71
- :content_type => 'application/vnd.ms-office.chartcolorstyle+xml')
72
- end
73
- }
74
-
75
- workbook.drawings.each_pair { |k, v|
76
- case k
77
- when /.xml$/ then
78
- overrides << RubyXL::ContentTypeOverride.new(:part_name => "/#{@workbook.drawings.local_dir_path}/#{k}",
79
- :content_type => 'application/vnd.openxmlformats-officedocument.drawing+xml')
80
- when /.vml$/ then
81
- # more proper fix: <Default Extension="vml" ContentType="application/vnd.openxmlformats-officedocument.vmlDrawing"/>
82
- overrides << RubyXL::ContentTypeOverride.new(:part_name => "/#{@workbook.drawings.local_dir_path}/#{k}",
83
- :content_type => 'application/vnd.openxmlformats-officedocument.vmlDrawing')
84
- end
85
- }
86
-
87
- unless workbook.external_links.nil?
88
- 1.upto(workbook.external_links.size - 1) { |i|
89
- overrides << RubyXL::ContentTypeOverride.new(:part_name => "/xl/externalLinks/externalLink#{i}.xml",
90
- :content_type => 'application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml')
91
- }
92
- end
93
-
94
- unless @workbook.macros.empty?
95
- overrides << RubyXL::ContentTypeOverride.new(:part_name => '/xl/vbaProject.bin',
96
- :content_type => 'application/vnd.ms-office.vbaProject')
97
- end
57
+ defaults << RubyXL::ContentTypeDefault.new(:extension => 'jpeg', :content_type => 'image/jpeg')
58
+ defaults << RubyXL::ContentTypeDefault.new(:extension => 'png', :content_type => 'image/png')
59
+ defaults << RubyXL::ContentTypeDefault.new(:extension => 'wmf', :content_type => 'image/x-wmf')
60
+ defaults << RubyXL::ContentTypeDefault.new(:extension => 'vml', :content_type => 'application/vnd.openxmlformats-officedocument.vmlDrawing')
98
61
 
99
- overrides.compact!
100
62
  true
101
63
  end
102
64
 
@@ -4,7 +4,10 @@ require 'rubyXL/objects/container_nodes'
4
4
  module RubyXL
5
5
 
6
6
  # http://www.schemacentral.com/sc/ooxml/e-extended-properties_Properties.html
7
- class DocumentProperties < OOXMLTopLevelObject
7
+ class DocumentPropertiesFile < OOXMLTopLevelObject
8
+ CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
9
+ REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties'
10
+
8
11
  attr_accessor :workbook
9
12
 
10
13
  define_child_node(RubyXL::StringNode, :node_name => :Template)
@@ -58,27 +61,26 @@ module RubyXL
58
61
  add_parts_count('Worksheets', @workbook.worksheets.size)
59
62
  @workbook.worksheets.each { |sheet| add_part_title(sheet.sheet_name) }
60
63
 
61
- if @workbook.defined_name_container then
62
- add_parts_count('Named Ranges', @workbook.defined_name_container.defined_names.size)
63
- @workbook.defined_name_container.defined_names.each { |defined_name| add_part_title(defined_name.name) }
64
+ if @workbook.defined_names then
65
+ add_parts_count('Named Ranges', @workbook.defined_names.size)
66
+ @workbook.defined_names.each { |defined_name| add_part_title(defined_name.name) }
64
67
  end
65
68
  end
66
69
 
67
70
  true
68
71
  end
69
72
 
70
- def self.xlsx_path
73
+ def xlsx_path
71
74
  File.join('docProps', 'app.xml')
72
75
  end
73
76
 
74
- def self.content_type
75
- 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
76
- end
77
-
78
77
  end
79
78
 
80
79
 
81
- class CoreProperties < OOXMLTopLevelObject
80
+ class CorePropertiesFile < OOXMLTopLevelObject
81
+ CONTENT_TYPE = 'application/vnd.openxmlformats-package.core-properties+xml'
82
+ REL_TYPE = 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties'
83
+
82
84
  attr_accessor :workbook
83
85
 
84
86
  define_child_node(RubyXL::StringNode, :node_name => 'dc:creator')
@@ -105,14 +107,10 @@ module RubyXL
105
107
  'http://www.w3.org/2001/XMLSchema-instance' => 'xsi')
106
108
  define_element_name 'cp:coreProperties'
107
109
 
108
- def self.xlsx_path
110
+ def xlsx_path
109
111
  File.join('docProps', 'core.xml')
110
112
  end
111
113
 
112
- def self.content_type
113
- 'application/vnd.openxmlformats-package.core-properties+xml'
114
- end
115
-
116
114
  def creator
117
115
  dc_creator && dc_creator.value
118
116
  end
@@ -103,7 +103,7 @@ module RubyXL
103
103
  define_attribute(:caseSensitive, :bool, :default => false)
104
104
  define_attribute(:sortMethod, RubyXL::ST_SortMethod, :default => 'none')
105
105
  define_attribute(:ref, :ref, :required => true)
106
- define_child_node(RubyXL::SortCondition, :colection => true)
106
+ define_child_node(RubyXL::SortCondition, :collection => true)
107
107
  define_child_node(RubyXL::ExtensionStorageArea)
108
108
  define_element_name 'sortState'
109
109
  end
@@ -63,7 +63,7 @@ module RubyXL
63
63
  # ==== Examples
64
64
  # define_child_node(RubyXL::Alignment)
65
65
  # Define a singular child node parsed by the RubyXL::BorderEdge.parse() and accessed by the default <tt>obj.alignment</tt> accessor
66
- # define_child_node(RubyXL::Hyperlink, :colection => true, :accessor => :hyperlinks)
66
+ # define_child_node(RubyXL::Hyperlink, :collection => true, :accessor => :hyperlinks)
67
67
  # Define an array of nodes accessed by <tt>obj.hyperlinks</tt> accessor, each of which will be parsed by the RubyXL::Hyperlink.parse()
68
68
  # define_child_node(RubyXL::BorderEdge, :node_name => :left)
69
69
  # define_child_node(RubyXL::BorderEdge, :node_name => :right)
@@ -109,7 +109,7 @@ module RubyXL
109
109
  end
110
110
 
111
111
  def parse(node, known_namespaces = nil)
112
- node = Nokogiri::XML.parse(node) if node.is_a?(IO) || node.is_a?(String)
112
+ node = Nokogiri::XML.parse(node) if node.is_a?(IO) || node.is_a?(String) || node.is_a?(Zip::InputStream)
113
113
 
114
114
  if node.is_a?(Nokogiri::XML::Document) then
115
115
  @namespaces = node.namespaces
@@ -274,7 +274,7 @@ module RubyXL
274
274
  val = val &&
275
275
  case v[:attr_type]
276
276
  when :bool then val ? '1' : '0'
277
- when :float then val.to_s.gsub(/\.0*$/, '') # Trim trailing zeroes
277
+ when :float then val.to_s.gsub(/\.0*\Z/, '') # Trim trailing zeroes
278
278
  else val
279
279
  end
280
280
 
@@ -396,11 +396,11 @@ module RubyXL
396
396
  # Prototype method. For top-level OOXML object, returns the path at which the current object's XML file
397
397
  # is located within the <tt>.xslx</tt> zip container.
398
398
  def xlsx_path
399
- self.class.xlsx_path
399
+ raise 'Subclass responsebility'
400
400
  end
401
401
 
402
- def self.xlsx_path
403
- raise 'Subclass responsebility'
402
+ def self.save_order
403
+ 500
404
404
  end
405
405
 
406
406
  # Sets the list of namespaces on this object to be added when writing out XML. Valid only on top-level objects.
@@ -417,11 +417,20 @@ module RubyXL
417
417
  # directory containing the unzipped contents of <tt>.xslx</tt>
418
418
  # === Parameters
419
419
  # * +dirpath+ - path to the directory with the unzipped <tt>.xslx</tt> contents.
420
- def self.parse_file(dirpath)
421
- full_path = File.join(dirpath, xlsx_path)
422
- return nil unless File.exist?(full_path)
423
- # Making sure that the file will be automatically closed immediately after it has been read
424
- File.open(full_path, 'r') { |f| parse(f) }
420
+ def self.parse_file(dirpath, file_path = nil)
421
+ file_path = Pathname.new(file_path || self.xlsx_path)
422
+
423
+ case dirpath
424
+ when String then
425
+ full_path = File.join(dirpath, file_path)
426
+ return nil unless File.exist?(full_path)
427
+ # Making sure that the file will be automatically closed immediately after it has been read
428
+ File.open(full_path, 'r') { |f| parse(f) }
429
+ when Zip::File then
430
+ file_path = file_path.relative_path_from(Pathname.new("/")) if file_path.absolute? # Zip doesn't like absolute paths.
431
+ entry = dirpath.find_entry(file_path)
432
+ entry && (entry.get_input_stream { |f| parse(f) })
433
+ end
425
434
  end
426
435
 
427
436
  # Saves the contents of the object as XML to respective location in <tt>.xslx</tt> zip container.
@@ -433,6 +442,10 @@ module RubyXL
433
442
  zipfile.get_output_stream(self.xlsx_path) { |f| f << xml_string }
434
443
  end
435
444
 
445
+ def file_index
446
+ @workbook.root.rels_hash[self.class].index{ |f| f.equal?(self) }.to_i + 1
447
+ end
448
+
436
449
  end
437
450
 
438
451
  end
@@ -87,7 +87,7 @@ module RubyXL
87
87
 
88
88
  # Converts Excel-style cell reference to +row+ and +col+ zero-based indices.
89
89
  def self.ref2ind(str)
90
- return [ -1, -1 ] unless str =~ /^([A-Z]+)(\d+)$/
90
+ return [ -1, -1 ] unless str =~ /\A([A-Z]+)(\d+)\Z/
91
91
 
92
92
  col = 0
93
93
  $1.each_byte { |chr| col = col * 26 + (chr - 64) }
@@ -7,9 +7,10 @@ module RubyXL
7
7
  end
8
8
 
9
9
  class Relationship < OOXMLObject
10
- define_attribute(:Id, :string)
11
- define_attribute(:Type, :string)
12
- define_attribute(:Target, :string)
10
+ define_attribute(:Id, :string)
11
+ define_attribute(:Type, :string)
12
+ define_attribute(:Target, :string)
13
+ define_attribute(:TargetMode, :string)
13
14
  define_element_name 'Relationship'
14
15
  end
15
16
 
@@ -18,19 +19,28 @@ module RubyXL
18
19
  define_element_name 'Relationships'
19
20
  set_namespaces('http://schemas.openxmlformats.org/package/2006/relationships' => '')
20
21
 
21
- def document_relationship(target, type)
22
+ attr_accessor :related_files, :owner
23
+
24
+ @@debug = nil # Change to 0 to enable debug output
25
+
26
+ def new_relationship(target, type)
22
27
  RubyXL::Relationship.new(:id => "rId#{relationships.size + 1}",
23
- :type => "http://schemas.openxmlformats.org/officeDocument/2006/relationships/#{type}",
28
+ :type => type,
24
29
  :target => target)
25
30
  end
26
- protected :document_relationship
31
+ protected :new_relationship
27
32
 
28
- def metadata_relationship(target, type)
29
- RubyXL::Relationship.new(:id => "rId#{relationships.size + 1}",
30
- :type => "http://schemas.openxmlformats.org/package/2006/relationships/metadata/#{type}",
31
- :target => target)
33
+ def add_relationship(obj)
34
+ return if obj.nil?
35
+ relationships << RubyXL::Relationship.new(:id => "rId#{relationships.size + 1}",
36
+ :type => obj.class::REL_TYPE,
37
+ :target => obj.xlsx_path)
38
+ end
39
+ protected :add_relationship
40
+
41
+ def self.save_order
42
+ 0
32
43
  end
33
- protected :metadata_relationship
34
44
 
35
45
  def find_by_rid(r_id)
36
46
  relationships.find { |r| r.id == r_id }
@@ -39,9 +49,70 @@ module RubyXL
39
49
  def find_by_target(target)
40
50
  relationships.find { |r| r.target == target }
41
51
  end
42
- end
43
52
 
53
+ def self.get_class_by_rel_type(rel_type)
54
+ unless defined?(@@rel_hash)
55
+ @@rel_hash = {}
56
+ RubyXL.constants.each { |c|
57
+ klass = RubyXL.const_get(c)
58
+
59
+ if klass.is_a?(Class) && klass.const_defined?(:REL_TYPE) then
60
+ @@rel_hash[klass::REL_TYPE] = klass
61
+ end
62
+ }
63
+ end
64
+
65
+ @@rel_hash[rel_type]
66
+ end
67
+
68
+ def load_related_files(zipdir_path, base_file_name = '')
69
+ self.related_files = {}
70
+
71
+ @@debug +=2 if @@debug
72
+
73
+ self.relationships.each { |rel|
74
+ next if rel.target_mode == 'External'
75
+
76
+ file_path = Pathname.new(rel.target)
77
+
78
+ if !file_path.absolute? then
79
+ file_path = (Pathname.new(File.dirname(base_file_name)) + file_path).cleanpath
80
+ end
81
+
82
+ klass = RubyXL::OOXMLRelationshipsFile.get_class_by_rel_type(rel.type)
83
+
84
+ if klass.nil? then
85
+ puts "*** WARNING: storage class not found for #{rel.target} (#{rel.type})"
86
+ klass = GenericStorageObject
87
+ end
88
+
89
+ puts "--> DEBUG:#{' ' * @@debug}Loading #{klass} (#{rel.id}): #{file_path}" if @@debug
90
+
91
+ obj = klass.parse_file(zipdir_path, file_path)
92
+ obj.load_relationships(zipdir_path, file_path) if obj.respond_to?(:load_relationships)
93
+ self.related_files[rel.id] = obj
94
+ }
95
+
96
+ @@debug -=2 if @@debug
97
+
98
+ related_files
99
+ end
100
+
101
+ def self.load_relationship_file(zipdir_path, base_file_path)
102
+ rel_file_path = Pathname.new(File.join(File.dirname(base_file_path), '_rels', File.basename(base_file_path) + '.rels')).cleanpath
103
+
104
+ puts "--> DEBUG: #{' ' * @@debug}Loading .rel file: #{rel_file_path}" if @@debug
105
+
106
+ parse_file(zipdir_path, rel_file_path)
107
+ end
108
+
109
+ def xlsx_path
110
+ file_path = owner.xlsx_path
111
+ File.join(File.dirname(file_path), '_rels', File.basename(file_path) + '.rels')
112
+ end
44
113
 
114
+ end
115
+
45
116
  class WorkbookRelationships < OOXMLRelationshipsFile
46
117
 
47
118
  attr_accessor :workbook
@@ -50,51 +121,96 @@ module RubyXL
50
121
  self.relationships = []
51
122
 
52
123
  @workbook.worksheets.each_with_index { |sheet, i|
53
- relationships << document_relationship(sheet.xlsx_path.gsub(/^xl\//, ''), sheet.rel_type)
124
+ relationships << new_relationship(sheet.xlsx_path.gsub(/\Axl\//, ''), sheet.class::REL_TYPE)
54
125
  }
55
126
 
56
- @workbook.external_links.each_key { |k|
57
- relationships << document_relationship("externalLinks/#{k}", 'externalLink')
58
- }
127
+ # @workbook.external_links.each_key { |k|
128
+ # relationships << new_relationship("externalLinks/#{k}", 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink')
129
+ # }
59
130
 
60
- relationships << document_relationship('theme/theme1.xml', 'theme') if @workbook.theme
61
- relationships << document_relationship('styles.xml', 'styles') if @workbook.stylesheet
131
+ relationships << new_relationship('theme/theme1.xml', @workbook.theme.class::REL_TYPE) if @workbook.theme
132
+ relationships << new_relationship('styles.xml', @workbook.stylesheet.class::REL_TYPE) if @workbook.stylesheet
62
133
 
63
134
  if @workbook.shared_strings_container && !@workbook.shared_strings_container.strings.empty? then
64
- relationships << document_relationship('sharedStrings.xml', 'sharedStrings')
135
+ relationships << new_relationship('sharedStrings.xml', @workbook.shared_strings_container.class::REL_TYPE)
65
136
  end
66
137
 
67
138
  if @workbook.calculation_chain && !@workbook.calculation_chain.cells.empty? then
68
- relationships << document_relationship('calcChain.xml', 'calcChain')
139
+ relationships << new_relationship('calcChain.xml', @workbook.calculation_chain.class::REL_TYPE)
69
140
  end
70
141
 
71
142
  true
72
143
  end
73
144
 
74
- def self.xlsx_path
75
- File.join('xl', '_rels', 'workbook.xml.rels')
76
- end
77
-
78
145
  end
79
146
 
80
147
  class RootRelationships < OOXMLRelationshipsFile
81
148
 
82
- attr_accessor :workbook
83
-
84
149
  def before_write_xml
85
150
  self.relationships = []
86
151
 
87
- relationships << document_relationship('xl/workbook.xml', 'officeDocument')
88
- relationships << metadata_relationship('docProps/thumbnail.jpeg', 'thumbnail') unless @workbook.thumbnail.empty?
89
- relationships << metadata_relationship('docProps/core.xml', 'core-properties') if @workbook.core_properties
90
- relationships << document_relationship('docProps/app.xml', 'extended-properties') if @workbook.document_properties
152
+ add_relationship(owner.workbook)
153
+ add_relationship(owner.thumbnail)
154
+ add_relationship(owner.core_properties)
155
+ add_relationship(owner.document_properties)
91
156
 
92
157
  true
93
158
  end
94
159
 
95
- def self.xlsx_path
160
+ def xlsx_path
96
161
  File.join('_rels', '.rels')
97
162
  end
98
163
  end
99
164
 
165
+ class SheetRelationshipsFile < OOXMLRelationshipsFile
166
+ # Insert class specific stuff here once we get to implementing it
167
+ end
168
+
169
+ class DrawingRelationshipsFile < OOXMLRelationshipsFile
170
+ # Insert class specific stuff here once we get to implementing it
171
+ end
172
+
173
+ class ChartRelationshipsFile < OOXMLRelationshipsFile
174
+ # Insert class specific stuff here once we get to implementing it
175
+ end
176
+
177
+ module RelationshipSupport
178
+
179
+ attr_accessor :generic_storage, :relationship_container
180
+ def related_objects # Override this method
181
+ []
182
+ end
183
+
184
+ def collect_related_objects
185
+ res = related_objects.compact # Avoid tainting +related_objects+ array
186
+
187
+ res += generic_storage if generic_storage
188
+
189
+ if relationship_container then
190
+ relationship_container.owner = self
191
+ res << relationship_container
192
+ end
193
+
194
+ res.each { |o| res += o.collect_related_objects if o.respond_to?(:collect_related_objects) }
195
+
196
+ res
197
+ end
198
+
199
+ def store_relationship(related_file, unknown = false)
200
+ self.generic_storage ||= []
201
+ puts "WARNING: #{self.class} is not aware what to do with #{related_file.class}" if unknown
202
+ self.generic_storage << related_file
203
+ end
204
+
205
+ def load_relationships(dir_path, base_file_name = '')
206
+ self.relationship_container = relationship_file_class.load_relationship_file(dir_path, base_file_name)
207
+ return if relationship_container.nil?
208
+
209
+ relationship_container.load_related_files(dir_path, base_file_name).each_pair { |rid, related_file|
210
+ attach_relationship(rid, related_file) if related_file
211
+ }
212
+ end
213
+
214
+ end
215
+
100
216
  end