rubyXL-ptr 3.3.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (457) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +17 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.rdoc +229 -0
  5. data/Rakefile +103 -0
  6. data/VERSION +1 -0
  7. data/lib/rubyXL.rb +12 -0
  8. data/lib/rubyXL/cell.rb +54 -0
  9. data/lib/rubyXL/convenience_methods.rb +1122 -0
  10. data/lib/rubyXL/objects/border.rb +74 -0
  11. data/lib/rubyXL/objects/calculation_chain.rb +31 -0
  12. data/lib/rubyXL/objects/cell_style.rb +65 -0
  13. data/lib/rubyXL/objects/chartsheet.rb +92 -0
  14. data/lib/rubyXL/objects/color.rb +27 -0
  15. data/lib/rubyXL/objects/column_range.rb +92 -0
  16. data/lib/rubyXL/objects/comments.rb +47 -0
  17. data/lib/rubyXL/objects/container_nodes.rb +135 -0
  18. data/lib/rubyXL/objects/content_types.rb +77 -0
  19. data/lib/rubyXL/objects/data_validation.rb +37 -0
  20. data/lib/rubyXL/objects/document_properties.rb +159 -0
  21. data/lib/rubyXL/objects/extensions.rb +40 -0
  22. data/lib/rubyXL/objects/external_links.rb +85 -0
  23. data/lib/rubyXL/objects/fill.rb +55 -0
  24. data/lib/rubyXL/objects/filters.rb +120 -0
  25. data/lib/rubyXL/objects/font.rb +48 -0
  26. data/lib/rubyXL/objects/formula.rb +24 -0
  27. data/lib/rubyXL/objects/ooxml_object.rb +460 -0
  28. data/lib/rubyXL/objects/reference.rb +110 -0
  29. data/lib/rubyXL/objects/relationships.rb +213 -0
  30. data/lib/rubyXL/objects/root.rb +86 -0
  31. data/lib/rubyXL/objects/shared_strings.rb +70 -0
  32. data/lib/rubyXL/objects/sheet_common.rb +51 -0
  33. data/lib/rubyXL/objects/sheet_data.rb +188 -0
  34. data/lib/rubyXL/objects/simple_types.rb +232 -0
  35. data/lib/rubyXL/objects/storage.rb +182 -0
  36. data/lib/rubyXL/objects/stylesheet.rb +232 -0
  37. data/lib/rubyXL/objects/text.rb +94 -0
  38. data/lib/rubyXL/objects/theme.rb +1716 -0
  39. data/lib/rubyXL/objects/workbook.rb +464 -0
  40. data/lib/rubyXL/objects/worksheet.rb +748 -0
  41. data/lib/rubyXL/parser.rb +29 -0
  42. data/lib/rubyXL/worksheet.rb +105 -0
  43. data/rdoc/README_rdoc.html +475 -0
  44. data/rdoc/RubyXL.html +598 -0
  45. data/rdoc/RubyXL/AExtension.html +223 -0
  46. data/rdoc/RubyXL/AExtensionStorageArea.html +103 -0
  47. data/rdoc/RubyXL/ActiveX.html +182 -0
  48. data/rdoc/RubyXL/ActiveXBinary.html +117 -0
  49. data/rdoc/RubyXL/AdjustHandleList.html +106 -0
  50. data/rdoc/RubyXL/Alignment.html +106 -0
  51. data/rdoc/RubyXL/AlternateContent.html +103 -0
  52. data/rdoc/RubyXL/Authors.html +106 -0
  53. data/rdoc/RubyXL/AutoFilter.html +106 -0
  54. data/rdoc/RubyXL/AutoFilterColumn.html +106 -0
  55. data/rdoc/RubyXL/BinaryImageFile.html +122 -0
  56. data/rdoc/RubyXL/BodyProperties.html +106 -0
  57. data/rdoc/RubyXL/BooleanNode.html +103 -0
  58. data/rdoc/RubyXL/BooleanValue.html +103 -0
  59. data/rdoc/RubyXL/Border.html +275 -0
  60. data/rdoc/RubyXL/BorderEdge.html +189 -0
  61. data/rdoc/RubyXL/Borders.html +157 -0
  62. data/rdoc/RubyXL/Break.html +106 -0
  63. data/rdoc/RubyXL/BreakList.html +106 -0
  64. data/rdoc/RubyXL/CT_AdjPoint2D.html +106 -0
  65. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +106 -0
  66. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +106 -0
  67. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +106 -0
  68. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +106 -0
  69. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +106 -0
  70. data/rdoc/RubyXL/CT_Backdrop.html +106 -0
  71. data/rdoc/RubyXL/CT_Bevel.html +106 -0
  72. data/rdoc/RubyXL/CT_BiLevelEffect.html +106 -0
  73. data/rdoc/RubyXL/CT_BlendEffect.html +106 -0
  74. data/rdoc/RubyXL/CT_Blip.html +106 -0
  75. data/rdoc/RubyXL/CT_BlipFillProperties.html +106 -0
  76. data/rdoc/RubyXL/CT_BlurEffect.html +106 -0
  77. data/rdoc/RubyXL/CT_Camera.html +106 -0
  78. data/rdoc/RubyXL/CT_Color.html +106 -0
  79. data/rdoc/RubyXL/CT_ColorChangeEffect.html +106 -0
  80. data/rdoc/RubyXL/CT_ColorMapping.html +106 -0
  81. data/rdoc/RubyXL/CT_ColorScheme.html +106 -0
  82. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +106 -0
  83. data/rdoc/RubyXL/CT_ConnectionSite.html +106 -0
  84. data/rdoc/RubyXL/CT_ConnectionSiteList.html +106 -0
  85. data/rdoc/RubyXL/CT_DashStop.html +106 -0
  86. data/rdoc/RubyXL/CT_DashStopList.html +106 -0
  87. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +106 -0
  88. data/rdoc/RubyXL/CT_DuotoneEffect.html +106 -0
  89. data/rdoc/RubyXL/CT_EffectContainer.html +106 -0
  90. data/rdoc/RubyXL/CT_EffectList.html +106 -0
  91. data/rdoc/RubyXL/CT_EffectReference.html +106 -0
  92. data/rdoc/RubyXL/CT_EffectStyleItem.html +106 -0
  93. data/rdoc/RubyXL/CT_EffectStyleList.html +106 -0
  94. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +106 -0
  95. data/rdoc/RubyXL/CT_FillEffect.html +106 -0
  96. data/rdoc/RubyXL/CT_FillOverlayEffect.html +106 -0
  97. data/rdoc/RubyXL/CT_FillStyleList.html +106 -0
  98. data/rdoc/RubyXL/CT_FlatText.html +106 -0
  99. data/rdoc/RubyXL/CT_FontCollection.html +106 -0
  100. data/rdoc/RubyXL/CT_FontReference.html +106 -0
  101. data/rdoc/RubyXL/CT_GeomGuideList.html +106 -0
  102. data/rdoc/RubyXL/CT_GlowEffect.html +106 -0
  103. data/rdoc/RubyXL/CT_GradientFillProperties.html +106 -0
  104. data/rdoc/RubyXL/CT_GradientStop.html +106 -0
  105. data/rdoc/RubyXL/CT_GradientStopList.html +106 -0
  106. data/rdoc/RubyXL/CT_HSLEffect.html +106 -0
  107. data/rdoc/RubyXL/CT_HslColor.html +106 -0
  108. data/rdoc/RubyXL/CT_Hyperlink.html +106 -0
  109. data/rdoc/RubyXL/CT_InnerShadowEffect.html +106 -0
  110. data/rdoc/RubyXL/CT_LightRig.html +106 -0
  111. data/rdoc/RubyXL/CT_LineEndProperties.html +106 -0
  112. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +106 -0
  113. data/rdoc/RubyXL/CT_LineProperties.html +106 -0
  114. data/rdoc/RubyXL/CT_LineStyleList.html +106 -0
  115. data/rdoc/RubyXL/CT_LinearShadeProperties.html +106 -0
  116. data/rdoc/RubyXL/CT_LuminanceEffect.html +106 -0
  117. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +106 -0
  118. data/rdoc/RubyXL/CT_OuterShadowEffect.html +106 -0
  119. data/rdoc/RubyXL/CT_Path2D.html +106 -0
  120. data/rdoc/RubyXL/CT_Path2DArcTo.html +106 -0
  121. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +106 -0
  122. data/rdoc/RubyXL/CT_Path2DList.html +106 -0
  123. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +106 -0
  124. data/rdoc/RubyXL/CT_Path2DTo.html +106 -0
  125. data/rdoc/RubyXL/CT_PathShadeProperties.html +106 -0
  126. data/rdoc/RubyXL/CT_PatternFillProperties.html +106 -0
  127. data/rdoc/RubyXL/CT_Point3D.html +106 -0
  128. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +106 -0
  129. data/rdoc/RubyXL/CT_PresetColor.html +106 -0
  130. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +106 -0
  131. data/rdoc/RubyXL/CT_PresetShadowEffect.html +106 -0
  132. data/rdoc/RubyXL/CT_PresetTextShape.html +106 -0
  133. data/rdoc/RubyXL/CT_ReflectionEffect.html +106 -0
  134. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +106 -0
  135. data/rdoc/RubyXL/CT_RelativeRect.html +106 -0
  136. data/rdoc/RubyXL/CT_SRgbColor.html +106 -0
  137. data/rdoc/RubyXL/CT_ScRgbColor.html +106 -0
  138. data/rdoc/RubyXL/CT_Scene3D.html +106 -0
  139. data/rdoc/RubyXL/CT_SchemeColor.html +106 -0
  140. data/rdoc/RubyXL/CT_Shape3D.html +106 -0
  141. data/rdoc/RubyXL/CT_ShapeStyle.html +106 -0
  142. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +106 -0
  143. data/rdoc/RubyXL/CT_SphereCoords.html +106 -0
  144. data/rdoc/RubyXL/CT_StretchInfoProperties.html +106 -0
  145. data/rdoc/RubyXL/CT_StyleMatrix.html +106 -0
  146. data/rdoc/RubyXL/CT_StyleMatrixReference.html +106 -0
  147. data/rdoc/RubyXL/CT_SupplementalFont.html +106 -0
  148. data/rdoc/RubyXL/CT_SystemColor.html +106 -0
  149. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +106 -0
  150. data/rdoc/RubyXL/CT_TextBlipBullet.html +106 -0
  151. data/rdoc/RubyXL/CT_TextCharBullet.html +106 -0
  152. data/rdoc/RubyXL/CT_TextCharacterProperties.html +106 -0
  153. data/rdoc/RubyXL/CT_TextFont.html +106 -0
  154. data/rdoc/RubyXL/CT_TextListStyle.html +106 -0
  155. data/rdoc/RubyXL/CT_TextNormalAutofit.html +106 -0
  156. data/rdoc/RubyXL/CT_TextParagraphProperties.html +106 -0
  157. data/rdoc/RubyXL/CT_TextSpacing.html +106 -0
  158. data/rdoc/RubyXL/CT_TextTabStop.html +106 -0
  159. data/rdoc/RubyXL/CT_TextTabStopList.html +106 -0
  160. data/rdoc/RubyXL/CT_TileInfoProperties.html +106 -0
  161. data/rdoc/RubyXL/CT_TintEffect.html +106 -0
  162. data/rdoc/RubyXL/CT_Transform2D.html +106 -0
  163. data/rdoc/RubyXL/CT_TransformEffect.html +106 -0
  164. data/rdoc/RubyXL/CT_Vector3D.html +106 -0
  165. data/rdoc/RubyXL/CT_XYAdjustHandle.html +106 -0
  166. data/rdoc/RubyXL/CalculationChain.html +176 -0
  167. data/rdoc/RubyXL/CalculationChainCell.html +106 -0
  168. data/rdoc/RubyXL/CalculationProperties.html +106 -0
  169. data/rdoc/RubyXL/Cell.html +558 -0
  170. data/rdoc/RubyXL/CellConvenienceMethods.html +1211 -0
  171. data/rdoc/RubyXL/CellExt.html +106 -0
  172. data/rdoc/RubyXL/CellSmartTag.html +106 -0
  173. data/rdoc/RubyXL/CellSmartTagProperty.html +106 -0
  174. data/rdoc/RubyXL/CellSmartTags.html +106 -0
  175. data/rdoc/RubyXL/CellStyle.html +106 -0
  176. data/rdoc/RubyXL/CellStyleXFs.html +157 -0
  177. data/rdoc/RubyXL/CellStyles.html +157 -0
  178. data/rdoc/RubyXL/CellValue.html +158 -0
  179. data/rdoc/RubyXL/CellWatch.html +106 -0
  180. data/rdoc/RubyXL/CellWatches.html +106 -0
  181. data/rdoc/RubyXL/CellXFs.html +161 -0
  182. data/rdoc/RubyXL/ChartColorsFile.html +122 -0
  183. data/rdoc/RubyXL/ChartFile.html +189 -0
  184. data/rdoc/RubyXL/ChartStyleFile.html +122 -0
  185. data/rdoc/RubyXL/ChartUserShapesFile.html +122 -0
  186. data/rdoc/RubyXL/Chartsheet.html +260 -0
  187. data/rdoc/RubyXL/ChartsheetPageSetup.html +106 -0
  188. data/rdoc/RubyXL/ChartsheetProperties.html +106 -0
  189. data/rdoc/RubyXL/ChartsheetProtection.html +106 -0
  190. data/rdoc/RubyXL/ChartsheetView.html +106 -0
  191. data/rdoc/RubyXL/ChartsheetViews.html +106 -0
  192. data/rdoc/RubyXL/Color.html +175 -0
  193. data/rdoc/RubyXL/ColorFilter.html +106 -0
  194. data/rdoc/RubyXL/ColorScale.html +106 -0
  195. data/rdoc/RubyXL/ColorSet.html +106 -0
  196. data/rdoc/RubyXL/Colors.html +106 -0
  197. data/rdoc/RubyXL/ColumnRange.html +245 -0
  198. data/rdoc/RubyXL/ColumnRanges.html +289 -0
  199. data/rdoc/RubyXL/Comment.html +106 -0
  200. data/rdoc/RubyXL/CommentList.html +106 -0
  201. data/rdoc/RubyXL/CommentsFile.html +197 -0
  202. data/rdoc/RubyXL/ConditionalFormatValue.html +106 -0
  203. data/rdoc/RubyXL/ConditionalFormatting.html +106 -0
  204. data/rdoc/RubyXL/ConditionalFormattingRule.html +106 -0
  205. data/rdoc/RubyXL/ContentTypeDefault.html +103 -0
  206. data/rdoc/RubyXL/ContentTypeOverride.html +103 -0
  207. data/rdoc/RubyXL/ContentTypes.html +248 -0
  208. data/rdoc/RubyXL/ControlPropertiesFile.html +117 -0
  209. data/rdoc/RubyXL/CorePropertiesFile.html +474 -0
  210. data/rdoc/RubyXL/CustomColor.html +106 -0
  211. data/rdoc/RubyXL/CustomColorList.html +106 -0
  212. data/rdoc/RubyXL/CustomFilter.html +106 -0
  213. data/rdoc/RubyXL/CustomFilters.html +106 -0
  214. data/rdoc/RubyXL/CustomGeometry.html +106 -0
  215. data/rdoc/RubyXL/CustomProperties.html +106 -0
  216. data/rdoc/RubyXL/CustomPropertiesFile.html +122 -0
  217. data/rdoc/RubyXL/CustomProperty.html +106 -0
  218. data/rdoc/RubyXL/CustomSheetView.html +106 -0
  219. data/rdoc/RubyXL/CustomSheetViews.html +106 -0
  220. data/rdoc/RubyXL/CustomWorkbookView.html +106 -0
  221. data/rdoc/RubyXL/CustomWorkbookViews.html +106 -0
  222. data/rdoc/RubyXL/CustomXMLFile.html +117 -0
  223. data/rdoc/RubyXL/DXF.html +106 -0
  224. data/rdoc/RubyXL/DXFs.html +106 -0
  225. data/rdoc/RubyXL/DataBar.html +106 -0
  226. data/rdoc/RubyXL/DataConsolidate.html +106 -0
  227. data/rdoc/RubyXL/DataConsolidationReference.html +106 -0
  228. data/rdoc/RubyXL/DataConsolidationReferences.html +106 -0
  229. data/rdoc/RubyXL/DataType.html +143 -0
  230. data/rdoc/RubyXL/DataValidation.html +106 -0
  231. data/rdoc/RubyXL/DataValidations.html +106 -0
  232. data/rdoc/RubyXL/DateGroupItem.html +106 -0
  233. data/rdoc/RubyXL/DefinedName.html +106 -0
  234. data/rdoc/RubyXL/DefinedNameExt.html +106 -0
  235. data/rdoc/RubyXL/DefinedNames.html +106 -0
  236. data/rdoc/RubyXL/DefinedNamesExt.html +106 -0
  237. data/rdoc/RubyXL/DocumentPropertiesFile.html +255 -0
  238. data/rdoc/RubyXL/DrawingFile.html +188 -0
  239. data/rdoc/RubyXL/DynamicFilter.html +106 -0
  240. data/rdoc/RubyXL/EmbeddedControl.html +106 -0
  241. data/rdoc/RubyXL/EmbeddedControls.html +106 -0
  242. data/rdoc/RubyXL/Extension.html +106 -0
  243. data/rdoc/RubyXL/ExtensionStorageArea.html +106 -0
  244. data/rdoc/RubyXL/Extents.html +106 -0
  245. data/rdoc/RubyXL/ExternalBook.html +106 -0
  246. data/rdoc/RubyXL/ExternalLinksFile.html +184 -0
  247. data/rdoc/RubyXL/ExternalReference.html +106 -0
  248. data/rdoc/RubyXL/ExternalReferences.html +106 -0
  249. data/rdoc/RubyXL/ExtraColorSchemeList.html +106 -0
  250. data/rdoc/RubyXL/FieldItem.html +106 -0
  251. data/rdoc/RubyXL/FileRecoveryProperties.html +106 -0
  252. data/rdoc/RubyXL/FileSharing.html +106 -0
  253. data/rdoc/RubyXL/FileVersion.html +106 -0
  254. data/rdoc/RubyXL/Fill.html +157 -0
  255. data/rdoc/RubyXL/Fills.html +157 -0
  256. data/rdoc/RubyXL/FilterContainer.html +106 -0
  257. data/rdoc/RubyXL/FloatNode.html +103 -0
  258. data/rdoc/RubyXL/FloatValue.html +103 -0
  259. data/rdoc/RubyXL/Font.html +184 -0
  260. data/rdoc/RubyXL/FontConvenienceMethods.html +603 -0
  261. data/rdoc/RubyXL/FontScheme.html +106 -0
  262. data/rdoc/RubyXL/Fonts.html +157 -0
  263. data/rdoc/RubyXL/Formula.html +106 -0
  264. data/rdoc/RubyXL/FunctionGroup.html +106 -0
  265. data/rdoc/RubyXL/FunctionGroups.html +106 -0
  266. data/rdoc/RubyXL/GenericStorageObject.html +298 -0
  267. data/rdoc/RubyXL/GradientFill.html +106 -0
  268. data/rdoc/RubyXL/HeaderFooterSettings.html +106 -0
  269. data/rdoc/RubyXL/Hyperlink.html +106 -0
  270. data/rdoc/RubyXL/HyperlinkRelFile.html +117 -0
  271. data/rdoc/RubyXL/Hyperlinks.html +106 -0
  272. data/rdoc/RubyXL/IconFilter.html +106 -0
  273. data/rdoc/RubyXL/IconSet.html +106 -0
  274. data/rdoc/RubyXL/IgnoredError.html +106 -0
  275. data/rdoc/RubyXL/IgnoredErrors.html +106 -0
  276. data/rdoc/RubyXL/IndexedColors.html +106 -0
  277. data/rdoc/RubyXL/InputCells.html +106 -0
  278. data/rdoc/RubyXL/IntegerNode.html +103 -0
  279. data/rdoc/RubyXL/IntegerValue.html +103 -0
  280. data/rdoc/RubyXL/LegacyCell.html +181 -0
  281. data/rdoc/RubyXL/LegacyWorksheet.html +355 -0
  282. data/rdoc/RubyXL/MRUColors.html +106 -0
  283. data/rdoc/RubyXL/MacrosFile.html +122 -0
  284. data/rdoc/RubyXL/MergedCell.html +106 -0
  285. data/rdoc/RubyXL/MergedCells.html +106 -0
  286. data/rdoc/RubyXL/NumFmt.html +106 -0
  287. data/rdoc/RubyXL/NumberFormat.html +158 -0
  288. data/rdoc/RubyXL/NumberFormats.html +172 -0
  289. data/rdoc/RubyXL/OLEObject.html +106 -0
  290. data/rdoc/RubyXL/OLEObjectFile.html +122 -0
  291. data/rdoc/RubyXL/OLEObjects.html +106 -0
  292. data/rdoc/RubyXL/OLESize.html +106 -0
  293. data/rdoc/RubyXL/OOXMLContainerObject.html +394 -0
  294. data/rdoc/RubyXL/OOXMLObject.html +118 -0
  295. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +532 -0
  296. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +564 -0
  297. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +603 -0
  298. data/rdoc/RubyXL/OOXMLTopLevelObject.html +384 -0
  299. data/rdoc/RubyXL/Offset.html +106 -0
  300. data/rdoc/RubyXL/OutlineProperties.html +106 -0
  301. data/rdoc/RubyXL/PageMargins.html +106 -0
  302. data/rdoc/RubyXL/PageSetup.html +106 -0
  303. data/rdoc/RubyXL/PageSetupProperties.html +106 -0
  304. data/rdoc/RubyXL/Pane.html +106 -0
  305. data/rdoc/RubyXL/Parser.html +204 -0
  306. data/rdoc/RubyXL/PatternFill.html +106 -0
  307. data/rdoc/RubyXL/PhoneticProperties.html +106 -0
  308. data/rdoc/RubyXL/PhoneticRun.html +106 -0
  309. data/rdoc/RubyXL/PivotArea.html +106 -0
  310. data/rdoc/RubyXL/PivotCache.html +106 -0
  311. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +133 -0
  312. data/rdoc/RubyXL/PivotCacheRecordsFile.html +122 -0
  313. data/rdoc/RubyXL/PivotCaches.html +106 -0
  314. data/rdoc/RubyXL/PivotReference.html +106 -0
  315. data/rdoc/RubyXL/PivotReferences.html +106 -0
  316. data/rdoc/RubyXL/PivotTableFile.html +133 -0
  317. data/rdoc/RubyXL/PivotTableSelection.html +106 -0
  318. data/rdoc/RubyXL/PresetGeometry.html +106 -0
  319. data/rdoc/RubyXL/PrintOptions.html +106 -0
  320. data/rdoc/RubyXL/PrinterSettingsFile.html +122 -0
  321. data/rdoc/RubyXL/ProtectedRange.html +106 -0
  322. data/rdoc/RubyXL/ProtectedRanges.html +106 -0
  323. data/rdoc/RubyXL/Protection.html +106 -0
  324. data/rdoc/RubyXL/RID.html +103 -0
  325. data/rdoc/RubyXL/RawOOXML.html +223 -0
  326. data/rdoc/RubyXL/Reference.html +640 -0
  327. data/rdoc/RubyXL/Relationship.html +103 -0
  328. data/rdoc/RubyXL/RelationshipSupport.html +419 -0
  329. data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +148 -0
  330. data/rdoc/RubyXL/RichText.html +159 -0
  331. data/rdoc/RubyXL/RichTextRun.html +157 -0
  332. data/rdoc/RubyXL/Row.html +439 -0
  333. data/rdoc/RubyXL/RowExt.html +106 -0
  334. data/rdoc/RubyXL/RunProperties.html +106 -0
  335. data/rdoc/RubyXL/Scenario.html +106 -0
  336. data/rdoc/RubyXL/Scenarios.html +106 -0
  337. data/rdoc/RubyXL/Selection.html +165 -0
  338. data/rdoc/RubyXL/ShapeGuide.html +106 -0
  339. data/rdoc/RubyXL/ShapeTextRectangle.html +106 -0
  340. data/rdoc/RubyXL/SharedStringsTable.html +424 -0
  341. data/rdoc/RubyXL/Sheet.html +106 -0
  342. data/rdoc/RubyXL/SheetCalculationProperties.html +106 -0
  343. data/rdoc/RubyXL/SheetData.html +192 -0
  344. data/rdoc/RubyXL/SheetDataExt.html +106 -0
  345. data/rdoc/RubyXL/SheetDataSet.html +106 -0
  346. data/rdoc/RubyXL/SheetName.html +106 -0
  347. data/rdoc/RubyXL/SheetNames.html +106 -0
  348. data/rdoc/RubyXL/Sheets.html +106 -0
  349. data/rdoc/RubyXL/SlicerCacheFile.html +122 -0
  350. data/rdoc/RubyXL/SlicerFile.html +122 -0
  351. data/rdoc/RubyXL/SmartTagProperties.html +106 -0
  352. data/rdoc/RubyXL/SmartTagType.html +106 -0
  353. data/rdoc/RubyXL/SmartTagTypes.html +106 -0
  354. data/rdoc/RubyXL/SmartTags.html +106 -0
  355. data/rdoc/RubyXL/SortCondition.html +106 -0
  356. data/rdoc/RubyXL/SortState.html +106 -0
  357. data/rdoc/RubyXL/Sqref.html +197 -0
  358. data/rdoc/RubyXL/Stop.html +106 -0
  359. data/rdoc/RubyXL/StringNode.html +103 -0
  360. data/rdoc/RubyXL/StringNodeW3C.html +197 -0
  361. data/rdoc/RubyXL/StringValue.html +103 -0
  362. data/rdoc/RubyXL/Stylesheet.html +354 -0
  363. data/rdoc/RubyXL/TableFile.html +122 -0
  364. data/rdoc/RubyXL/TableParts.html +103 -0
  365. data/rdoc/RubyXL/TableStyle.html +106 -0
  366. data/rdoc/RubyXL/TableStyles.html +106 -0
  367. data/rdoc/RubyXL/Text.html +216 -0
  368. data/rdoc/RubyXL/Theme.html +535 -0
  369. data/rdoc/RubyXL/ThemeElements.html +106 -0
  370. data/rdoc/RubyXL/ThumbnailFile.html +122 -0
  371. data/rdoc/RubyXL/Top10.html +106 -0
  372. data/rdoc/RubyXL/VMLDrawingFile.html +134 -0
  373. data/rdoc/RubyXL/Variant.html +106 -0
  374. data/rdoc/RubyXL/Vector.html +161 -0
  375. data/rdoc/RubyXL/VectorValue.html +103 -0
  376. data/rdoc/RubyXL/VisualProperties.html +106 -0
  377. data/rdoc/RubyXL/WebPublishObject.html +106 -0
  378. data/rdoc/RubyXL/WebPublishObjects.html +106 -0
  379. data/rdoc/RubyXL/WebPublishingItem.html +106 -0
  380. data/rdoc/RubyXL/WebPublishingItems.html +106 -0
  381. data/rdoc/RubyXL/WebPublishingProperties.html +106 -0
  382. data/rdoc/RubyXL/Workbook.html +633 -0
  383. data/rdoc/RubyXL/WorkbookConvenienceMethods.html +1321 -0
  384. data/rdoc/RubyXL/WorkbookProperties.html +106 -0
  385. data/rdoc/RubyXL/WorkbookProtection.html +106 -0
  386. data/rdoc/RubyXL/WorkbookRoot.html +402 -0
  387. data/rdoc/RubyXL/WorkbookView.html +106 -0
  388. data/rdoc/RubyXL/WorkbookViews.html +106 -0
  389. data/rdoc/RubyXL/Worksheet.html +433 -0
  390. data/rdoc/RubyXL/WorksheetConvenienceMethods.html +2861 -0
  391. data/rdoc/RubyXL/WorksheetDimensions.html +106 -0
  392. data/rdoc/RubyXL/WorksheetFormatProperties.html +103 -0
  393. data/rdoc/RubyXL/WorksheetProperties.html +106 -0
  394. data/rdoc/RubyXL/WorksheetProtection.html +106 -0
  395. data/rdoc/RubyXL/WorksheetView.html +106 -0
  396. data/rdoc/RubyXL/WorksheetViews.html +106 -0
  397. data/rdoc/RubyXL/XF.html +106 -0
  398. data/rdoc/created.rid +38 -0
  399. data/rdoc/css/fonts.css +167 -0
  400. data/rdoc/css/rdoc.css +590 -0
  401. data/rdoc/fonts/Lato-Light.ttf +0 -0
  402. data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
  403. data/rdoc/fonts/Lato-Regular.ttf +0 -0
  404. data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
  405. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  406. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  407. data/rdoc/images/add.png +0 -0
  408. data/rdoc/images/arrow_up.png +0 -0
  409. data/rdoc/images/brick.png +0 -0
  410. data/rdoc/images/brick_link.png +0 -0
  411. data/rdoc/images/bug.png +0 -0
  412. data/rdoc/images/bullet_black.png +0 -0
  413. data/rdoc/images/bullet_toggle_minus.png +0 -0
  414. data/rdoc/images/bullet_toggle_plus.png +0 -0
  415. data/rdoc/images/date.png +0 -0
  416. data/rdoc/images/delete.png +0 -0
  417. data/rdoc/images/find.png +0 -0
  418. data/rdoc/images/loadingAnimation.gif +0 -0
  419. data/rdoc/images/macFFBgHack.png +0 -0
  420. data/rdoc/images/package.png +0 -0
  421. data/rdoc/images/page_green.png +0 -0
  422. data/rdoc/images/page_white_text.png +0 -0
  423. data/rdoc/images/page_white_width.png +0 -0
  424. data/rdoc/images/plugin.png +0 -0
  425. data/rdoc/images/ruby.png +0 -0
  426. data/rdoc/images/tag_blue.png +0 -0
  427. data/rdoc/images/tag_green.png +0 -0
  428. data/rdoc/images/transparent.png +0 -0
  429. data/rdoc/images/wrench.png +0 -0
  430. data/rdoc/images/wrench_orange.png +0 -0
  431. data/rdoc/images/zoom.png +0 -0
  432. data/rdoc/index.html +796 -0
  433. data/rdoc/js/darkfish.js +161 -0
  434. data/rdoc/js/jquery.js +4 -0
  435. data/rdoc/js/navigation.js +142 -0
  436. data/rdoc/js/navigation.js.gz +0 -0
  437. data/rdoc/js/search.js +109 -0
  438. data/rdoc/js/search_index.js +1 -0
  439. data/rdoc/js/search_index.js.gz +0 -0
  440. data/rdoc/js/searcher.js +229 -0
  441. data/rdoc/js/searcher.js.gz +0 -0
  442. data/rdoc/table_of_contents.html +2758 -0
  443. data/rubyXL.gemspec +516 -0
  444. data/spec/lib/cell_spec.rb +515 -0
  445. data/spec/lib/color_spec.rb +13 -0
  446. data/spec/lib/parser_spec.rb +118 -0
  447. data/spec/lib/reference_spec.rb +28 -0
  448. data/spec/lib/stylesheet_spec.rb +28 -0
  449. data/spec/lib/text_spec.rb +29 -0
  450. data/spec/lib/workbook_spec.rb +174 -0
  451. data/spec/lib/worksheet_spec.rb +1363 -0
  452. data/spec/spec_helper.rb +11 -0
  453. data/test/input/.gitkeep +0 -0
  454. data/test/output/.gitkeep +0 -0
  455. data/test/test_parse_write.rb +15 -0
  456. data/tmp/.gitignore +1 -0
  457. metadata +615 -0
@@ -0,0 +1,120 @@
1
+ require 'rubyXL/objects/ooxml_object'
2
+ require 'rubyXL/objects/simple_types'
3
+ require 'rubyXL/objects/extensions'
4
+
5
+ module RubyXL
6
+
7
+ # http://www.datypic.com/sc/ooxml/e-ssml_dateGroupItem-1.html
8
+ class DateGroupItem < OOXMLObject
9
+ define_attribute(:year, :int, :required => true)
10
+ define_attribute(:month, :int)
11
+ define_attribute(:day, :int)
12
+ define_attribute(:hour, :int)
13
+ define_attribute(:minute, :int)
14
+ define_attribute(:second, :int)
15
+ define_attribute(:dateTimeGrouping, RubyXL::ST_DateTimeGrouping)
16
+ define_element_name 'dateGroupItem'
17
+ end
18
+
19
+ # http://www.datypic.com/sc/ooxml/e-ssml_filters-1.html
20
+ class FilterContainer < OOXMLObject
21
+ define_attribute(:blank, :bool, :default => false)
22
+ define_attribute(:calendarType, RubyXL::ST_CalendarType, :default => 'none')
23
+ define_child_node(RubyXL::StringValue, :collection => true, :accessor => :filters, :node_name => :filter)
24
+ define_child_node(RubyXL::DateGroupItem, :collection => true, :accessor => :date_group_items)
25
+ define_element_name 'filters'
26
+ end
27
+
28
+ # http://www.datypic.com/sc/ooxml/e-ssml_top10-1.html
29
+ class Top10 < OOXMLObject
30
+ define_attribute(:top, :bool, :default => true)
31
+ define_attribute(:percent, :bool, :default => false)
32
+ define_attribute(:val, :double, :required => true)
33
+ define_attribute(:filterVal, :double)
34
+ define_element_name 'top10'
35
+ end
36
+
37
+ # http://www.datypic.com/sc/ooxml/e-ssml_customFilter-1.html
38
+ class CustomFilter < OOXMLObject
39
+ define_attribute(:operator, RubyXL::ST_FilterOperator, :default => 'equal')
40
+ define_attribute(:val, :string)
41
+ define_element_name 'customFilter'
42
+ end
43
+
44
+ # http://www.datypic.com/sc/ooxml/e-ssml_customFilters-1.html
45
+ class CustomFilters < OOXMLContainerObject
46
+ define_attribute(:and, :bool, :default => false)
47
+ define_child_node(RubyXL::CustomFilter, :collection => true)
48
+ define_element_name 'customFilters'
49
+ end
50
+
51
+ # http://www.datypic.com/sc/ooxml/e-ssml_dynamicFilter-1.html
52
+ class DynamicFilter < OOXMLObject
53
+ define_attribute(:type, RubyXL::ST_DynamicFilterType, :required => true)
54
+ define_attribute(:val, :double)
55
+ define_attribute(:maxVal, :double)
56
+ define_element_name 'dynamicFilter'
57
+ end
58
+
59
+ # http://www.datypic.com/sc/ooxml/e-ssml_colorFilter-1.html
60
+ class ColorFilter < OOXMLObject
61
+ define_attribute(:dxfId, :string)
62
+ define_attribute(:cellColor, :bool)
63
+ define_element_name 'colorFilter'
64
+ end
65
+
66
+ # http://www.datypic.com/sc/ooxml/e-ssml_iconFilter-1.html
67
+ class IconFilter < OOXMLObject
68
+ define_attribute(:iconSet, RubyXL::ST_IconSetType)
69
+ define_attribute(:iconId, :int)
70
+ define_element_name 'iconFilter'
71
+ end
72
+
73
+ # http://www.datypic.com/sc/ooxml/e-ssml_filterColumn-1.html
74
+ class AutoFilterColumn < OOXMLObject
75
+ define_attribute(:colId, :int, :required => true)
76
+ define_attribute(:hiddenButton, :bool, :default => false)
77
+ define_attribute(:showButton, :bool, :default => true)
78
+ define_child_node(RubyXL::FilterContainer)
79
+ define_child_node(RubyXL::Top10)
80
+ define_child_node(RubyXL::CustomFilters)
81
+ define_child_node(RubyXL::DynamicFilter)
82
+ define_child_node(RubyXL::ColorFilter)
83
+ define_child_node(RubyXL::IconFilter)
84
+ define_child_node(RubyXL::ExtensionStorageArea)
85
+ define_element_name 'filterColumn'
86
+ end
87
+
88
+ # http://www.datypic.com/sc/ooxml/e-ssml_sortCondition-1.html
89
+ class SortCondition < OOXMLObject
90
+ define_attribute(:descending, :bool, :default => false)
91
+ define_attribute(:sortBy, RubyXL::ST_SortBy, :default => 'value')
92
+ define_attribute(:ref, :ref, :required => true)
93
+ define_attribute(:customList, :string)
94
+ define_attribute(:dxfId, :int)
95
+ define_attribute(:iconSet, RubyXL::ST_IconSetType, :required => true, :default => '3Arrows')
96
+ define_attribute(:iconId, :int)
97
+ define_element_name 'sortCondition'
98
+ end
99
+
100
+ # http://www.datypic.com/sc/ooxml/e-ssml_sortState-2.html
101
+ class SortState < OOXMLObject
102
+ define_attribute(:columnSort, :bool, :default => false)
103
+ define_attribute(:caseSensitive, :bool, :default => false)
104
+ define_attribute(:sortMethod, RubyXL::ST_SortMethod, :default => 'none')
105
+ define_attribute(:ref, :ref, :required => true)
106
+ define_child_node(RubyXL::SortCondition, :collection => true)
107
+ define_child_node(RubyXL::ExtensionStorageArea)
108
+ define_element_name 'sortState'
109
+ end
110
+
111
+ # http://www.datypic.com/sc/ooxml/e-ssml_autoFilter-2.html
112
+ class AutoFilter < OOXMLObject
113
+ define_attribute(:ref, :ref)
114
+ define_child_node(RubyXL::AutoFilterColumn)
115
+ define_child_node(RubyXL::SortState)
116
+ define_child_node(RubyXL::ExtensionStorageArea)
117
+ define_element_name 'autoFilter'
118
+ end
119
+
120
+ end
@@ -0,0 +1,48 @@
1
+ require 'rubyXL/objects/ooxml_object'
2
+ require 'rubyXL/objects/container_nodes'
3
+ require 'rubyXL/objects/color'
4
+ require 'rubyXL/convenience_methods'
5
+
6
+ module RubyXL
7
+
8
+ # http://www.datypic.com/sc/ooxml/e-ssml_font-1.html
9
+ class Font < OOXMLObject
10
+ # Since we have no capability to load the actual fonts, we'll have to live with the default.
11
+ MAX_DIGIT_WIDTH = 7 # Calibri 11 pt @ 96 dpi
12
+
13
+ define_child_node(RubyXL::StringValue, :node_name => :name)
14
+ define_child_node(RubyXL::IntegerValue, :node_name => :charset)
15
+ define_child_node(RubyXL::IntegerValue, :node_name => :family)
16
+ define_child_node(RubyXL::BooleanValue, :node_name => :b)
17
+ define_child_node(RubyXL::BooleanValue, :node_name => :i)
18
+ define_child_node(RubyXL::BooleanValue, :node_name => :strike)
19
+ define_child_node(RubyXL::BooleanValue, :node_name => :outline)
20
+ define_child_node(RubyXL::BooleanValue, :node_name => :shadow)
21
+ define_child_node(RubyXL::BooleanValue, :node_name => :condense)
22
+ define_child_node(RubyXL::BooleanValue, :node_name => :extend)
23
+ define_child_node(RubyXL::Color)
24
+ define_child_node(RubyXL::FloatValue, :node_name => :sz)
25
+ define_child_node(RubyXL::BooleanValue, :node_name => :u)
26
+ define_child_node(RubyXL::StringValue, :node_name => :vertAlign)
27
+ define_child_node(RubyXL::StringValue, :node_name => :scheme)
28
+ define_element_name 'font'
29
+
30
+ def self.default(size = 10)
31
+ self.new(:name => RubyXL::StringValue.new(:val => 'Verdana'),
32
+ :sz => RubyXL::FloatValue.new(:val => size) )
33
+ end
34
+
35
+ include FontConvenienceMethods
36
+ end
37
+
38
+ # http://www.datypic.com/sc/ooxml/e-ssml_fonts-1.html
39
+ class Fonts < OOXMLContainerObject
40
+ define_child_node(RubyXL::Font, :collection => :with_count)
41
+ define_element_name 'fonts'
42
+
43
+ def self.default
44
+ self.new(:_ => [ RubyXL::Font.default(10), RubyXL::Font.default(8) ])
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubyXL/objects/ooxml_object'
2
+ require 'rubyXL/objects/simple_types'
3
+
4
+ module RubyXL
5
+
6
+ # http://www.datypic.com/sc/ooxml/e-ssml_f-1.html
7
+ class Formula < OOXMLObject
8
+ define_attribute(:_, :string, :accessor => :expression)
9
+ define_attribute(:t, RubyXL::ST_CellFormulaType, :default => 'normal')
10
+ define_attribute(:aca, :bool, :default => false)
11
+ define_attribute(:ref, :ref)
12
+ define_attribute(:dt2D, :bool, :default => false)
13
+ define_attribute(:dtr, :bool, :default => false)
14
+ define_attribute(:del1, :bool, :default => false)
15
+ define_attribute(:del2, :bool, :default => false)
16
+ define_attribute(:r1, :ref)
17
+ define_attribute(:r2, :ref)
18
+ define_attribute(:ca, :bool, :default => false)
19
+ define_attribute(:si, :int)
20
+ define_attribute(:bx, :bool, :default => false)
21
+ define_element_name 'f'
22
+ end
23
+
24
+ end
@@ -0,0 +1,460 @@
1
+ require 'nokogiri'
2
+ require 'pathname'
3
+ require 'rubyXL/objects/reference'
4
+
5
+ module RubyXL
6
+ module OOXMLObjectClassMethods
7
+ # Get the value of a [sub]class variable if it exists, or create the respective variable
8
+ # with the passed-in +default+ (or +{}+, if not specified)
9
+ #
10
+ # Throughout this class, we are setting class variables through explicit method calls
11
+ # rather than by directly addressing the name of the variable because of context issues:
12
+ # addressing variable by name creates it in the context of defining class, while calling
13
+ # the setter/getter method addresses it in the context of descendant class,
14
+ # which is what we need.
15
+ def obtain_class_variable(var_name, default = {})
16
+ self.class_variable_get(var_name)
17
+ rescue NameError
18
+ self.class_variable_set(var_name, default)
19
+ end
20
+
21
+ # Defines an attribute of OOXML object.
22
+ # === Parameters
23
+ # * +attribute_name+ - Name of the element attribute as seen in the source XML. Can be either <tt>"String"</tt> or <tt>:Symbol</tt>
24
+ # * Special attibute name <tt>'_'</tt> (underscore) denotes the value of the element rather than attribute.
25
+ # * +attribute_type+ - Specifies the conversion type for the attribute when parsing. Available options are:
26
+ # * +:int+ - <tt>Integer</tt>
27
+ # * +:uint+ - Unsigned <tt>Integer</tt>
28
+ # * +:double+ - <tt>Float</tt></u>
29
+ # * +:string+ - <tt>String</tt> (no conversion)
30
+ # * +:sqref+ - RubyXL::Sqref
31
+ # * +:ref+ - RubyXL::Reference
32
+ # * +:bool+ - <tt>Boolean</tt> ("1" and "true" convert to +true+, others to +false+)
33
+ # * one of +simple_types+ - <tt>String</tt>, plus the list of acceptable values is saved for future validation (not used yet).
34
+ # * +extra_parameters+ - Hash of optional parameters as follows:
35
+ # * +:accessor+ - Name of the accessor for this attribute to be defined on the object. If not provided, defaults to classidied +attribute_name+.
36
+ # * +:default+ - Value this attribute defaults to if not explicitly provided.
37
+ # * +:required+ - Whether this attribute is required when writing XML. If the value of the attrinute is not explicitly provided, +:default+ is written instead.
38
+ # * +:computed+ - Do not store this attribute on +parse+, but do call the object-provided read accessor on +write_xml+.
39
+ # ==== Examples
40
+ # define_attribute(:outline, :bool, :default => true)
41
+ # A <tt>Boolean</tt> attribute 'outline' with default value +true+ will be accessible by calling +obj.outline+
42
+ # define_attribute(:uniqueCount, :int)
43
+ # An <tt>Integer</tt> attribute 'uniqueCount' accessible as +obj.unique_count+
44
+ # define_attribute(:_, :string, :accessor => :expression)
45
+ # The value of the element will be accessible as a <tt>String</tt> by calling +obj.expression+
46
+ # define_attribute(:errorStyle, %w{ stop warning information }, :default => 'stop',)
47
+ # A <tt>String</tt> attribute named 'errorStyle' will be accessible as +obj.error_style+, valid values are <tt>"stop"</tt>, <tt>"warning"</tt>, <tt>"information"</tt>
48
+ def define_attribute(attr_name, attr_type, extra_params = {})
49
+ attrs = obtain_class_variable(:@@ooxml_attributes)
50
+ attr_hash = extra_params.merge({ :attr_type => attr_type })
51
+ attr_hash[:accessor] ||= accessorize(attr_name)
52
+ attrs[attr_name.to_s] = attr_hash
53
+ self.send(:attr_accessor, attr_hash[:accessor]) unless attr_hash[:computed]
54
+ end
55
+
56
+ # Defines a child node of OOXML object.
57
+ # === Parameters
58
+ # * +klass+ - Class (descendant of RubyXL::OOXMLObject) of the child nodes. Child node objects will be produced by calling +parse+ method of that class.
59
+ # * +extra_parameters+ - Hash of optional parameters as follows:
60
+ # * +:accessor+ - Name of the accessor for this attribute to be defined on the object. If not provided, defaults to classidied +attribute_name+.
61
+ # * +:node_name+ - Node name for the child node, in case it does not match the one defined by the +klass+.
62
+ # * +:collection+ - Whether the child node should be treated as a single node or a collection of nodes:
63
+ # * +false+ (default) - child node is directly accessible through the respective accessor;
64
+ # * +true+ - a collection of child nodes is accessed as +Array+ through the respective accessor;
65
+ # * +:with_count+ - same as +true+, but in addition, the attribute +count+ is defined on the current object, that will be automatically set to the number of elements in the collection at the start of +write_xml+ call.
66
+ # ==== Examples
67
+ # define_child_node(RubyXL::Alignment)
68
+ # Define a singular child node parsed by the RubyXL::BorderEdge.parse() and accessed by the default <tt>obj.alignment</tt> accessor
69
+ # define_child_node(RubyXL::Hyperlink, :collection => true, :accessor => :hyperlinks)
70
+ # Define an array of nodes accessed by <tt>obj.hyperlinks</tt> accessor, each of which will be parsed by the RubyXL::Hyperlink.parse()
71
+ # define_child_node(RubyXL::BorderEdge, :node_name => :left)
72
+ # define_child_node(RubyXL::BorderEdge, :node_name => :right)
73
+ # Use class RubyXL::BorderEdge when parsing both the elements <tt><left ...></tt> and <tt><right ...></tt> elements.
74
+ # define_child_node(RubyXL::Font, :collection => :with_count, :accessor => :fonts)
75
+ # Upon writing of the object this was defined on, its <tt>count</tt> attribute will be set to the count of nodes in <tt>fonts</tt> array
76
+ def define_child_node(klass, extra_params = {})
77
+ child_nodes = obtain_class_variable(:@@ooxml_child_nodes)
78
+ child_node_name = (extra_params[:node_name] || klass.class_variable_get(:@@ooxml_tag_name)).to_s
79
+ accessor = (extra_params[:accessor] || accessorize(child_node_name)).to_sym
80
+
81
+ child_nodes[child_node_name] = {
82
+ :class => klass,
83
+ :is_array => extra_params[:collection],
84
+ :accessor => accessor
85
+ }
86
+
87
+ define_count_attribute if extra_params[:collection] == :with_count
88
+
89
+ self.send(:attr_accessor, accessor)
90
+ end
91
+
92
+ def define_count_attribute
93
+ define_attribute(:count, :uint, :required => true)
94
+ end
95
+ private :define_count_attribute
96
+
97
+ # Defines the name of the element that represents the current OOXML object. Should only be used once per object.
98
+ # In case of different objects represented by the same class in different parts of OOXML tree, +:node_name+
99
+ # extra parameter can be used to override the default element name.
100
+ # === Parameters
101
+ # * +element_name+
102
+ # ==== Examples
103
+ # define_element_name 'externalReference'
104
+ def define_element_name(element_name)
105
+ self.class_variable_set(:@@ooxml_tag_name, element_name)
106
+ end
107
+
108
+ def parse(node, known_namespaces = nil)
109
+ case node
110
+ when String, IO, Zip::InputStream then node = Nokogiri::XML.parse(node)
111
+ end
112
+
113
+ if node.is_a?(Nokogiri::XML::Document) then
114
+ node = node.root
115
+ # ignorable_attr = node.attributes['Ignorable']
116
+ # @ignorables << ignorable_attr.value if ignorable_attr
117
+ end
118
+
119
+ obj = self.new
120
+ obj.local_namespaces = node.namespace_definitions
121
+
122
+ known_attributes = obtain_class_variable(:@@ooxml_attributes)
123
+
124
+ content_params = known_attributes['_']
125
+ process_attribute(obj, node.text, content_params) if content_params
126
+
127
+ node.attributes.each_pair { |attr_name, attr|
128
+ attr_name = if attr.namespace then "#{attr.namespace.prefix}:#{attr.name}"
129
+ else attr.name
130
+ end
131
+
132
+ attr_params = known_attributes[attr_name]
133
+
134
+ next if attr_params.nil?
135
+ # raise "Unknown attribute [#{attr_name}] for element [#{node.name}]" if attr_params.nil?
136
+ process_attribute(obj, attr.value, attr_params) unless attr_params[:computed]
137
+ }
138
+
139
+ known_child_nodes = obtain_class_variable(:@@ooxml_child_nodes)
140
+
141
+ unless known_child_nodes.empty?
142
+ known_namespaces ||= obtain_class_variable(:@@ooxml_namespaces)
143
+
144
+ node.element_children.each { |child_node|
145
+
146
+ ns = child_node.namespace
147
+ prefix = known_namespaces[ns.href] || ns.prefix
148
+
149
+ child_node_name = case prefix
150
+ when '', nil then child_node.name
151
+ else "#{prefix}:#{child_node.name}"
152
+ end
153
+
154
+ child_node_params = known_child_nodes[child_node_name]
155
+ raise "Unknown child node [#{child_node_name}] for element [#{node.name}]" if child_node_params.nil?
156
+ parsed_object = child_node_params[:class].parse(child_node, known_namespaces)
157
+ if child_node_params[:is_array] then
158
+ index = parsed_object.index_in_collection
159
+
160
+ collection = if (self < RubyXL::OOXMLContainerObject) then obj
161
+ else obj.send(child_node_params[:accessor])
162
+ end
163
+
164
+ if index.nil? then
165
+ collection << parsed_object
166
+ else
167
+ collection[index] = parsed_object
168
+ end
169
+ else
170
+ obj.send("#{child_node_params[:accessor]}=", parsed_object)
171
+ end
172
+ }
173
+ end
174
+
175
+ obj
176
+ end
177
+
178
+ private
179
+ def accessorize(str)
180
+ acc = str.to_s.dup
181
+ acc.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
182
+ acc.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
183
+ acc.gsub!(':','_')
184
+ acc.downcase.to_sym
185
+ end
186
+
187
+ def process_attribute(obj, raw_value, params)
188
+ val = raw_value &&
189
+ case params[:attr_type]
190
+ when :double then Float(raw_value) # http://www.datypic.com/sc/xsd/t-xsd_double.html
191
+ when :string then raw_value
192
+ when Array then raw_value # Case of Simple Types
193
+ when :sqref then RubyXL::Sqref.new(raw_value)
194
+ when :ref then RubyXL::Reference.new(raw_value)
195
+ when :bool then ['1', 'true'].include?(raw_value) # http://www.datypic.com/sc/xsd/t-xsd_boolean.html
196
+ when :int then Integer(raw_value)
197
+ when :uint then
198
+ v = Integer(raw_value)
199
+ raise ArgumentError.new("invalid value for unsigned Integer(): \"#{raw_value}\"") if v < 0
200
+ v
201
+ end
202
+ obj.send("#{params[:accessor]}=", val)
203
+ end
204
+
205
+ end
206
+
207
+
208
+ module OOXMLObjectInstanceMethods
209
+ attr_accessor :local_namespaces
210
+
211
+ def self.included(klass)
212
+ klass.extend RubyXL::OOXMLObjectClassMethods
213
+ end
214
+
215
+ def obtain_class_variable(var_name, default = {})
216
+ self.class.obtain_class_variable(var_name, default)
217
+ end
218
+ private :obtain_class_variable
219
+
220
+ def initialize(params = {})
221
+ @local_namespaces = nil
222
+
223
+ obtain_class_variable(:@@ooxml_attributes).each_value { |v|
224
+ instance_variable_set("@#{v[:accessor]}", params[v[:accessor]]) unless v[:computed]
225
+ }
226
+
227
+ init_child_nodes(params)
228
+ end
229
+
230
+ def init_child_nodes(params)
231
+ obtain_class_variable(:@@ooxml_child_nodes).each_value { |v|
232
+
233
+ initial_value =
234
+ if params.has_key?(v[:accessor]) then params[v[:accessor]]
235
+ elsif v[:is_array] then []
236
+ else nil
237
+ end
238
+
239
+ instance_variable_set("@#{v[:accessor]}", initial_value)
240
+ }
241
+ end
242
+ private :init_child_nodes
243
+
244
+ def preserve_whitespace
245
+ self.xml_space = (value.is_a?(String) && ((value =~ /\A\s/) || (value =~ /\s\Z/) || value.include?("\n"))) ? 'preserve' : nil
246
+ end
247
+ private :preserve_whitespace
248
+
249
+ def ==(other)
250
+ other.is_a?(self.class) &&
251
+ obtain_class_variable(:@@ooxml_attributes).all? { |k, v| self.send(v[:accessor]) == other.send(v[:accessor]) } &&
252
+ obtain_class_variable(:@@ooxml_child_nodes).all? { |k, v| self.send(v[:accessor]) == other.send(v[:accessor]) }
253
+ end
254
+
255
+ # Recursively write the OOXML object and all its children out as Nokogiri::XML. Immediately before the actual
256
+ # generation, +before_write_xml()+ is called to perform last-minute cleanup and validation operations; if it
257
+ # returns +false+, an empty string is returned (rather than +nil+, so Nokogiri::XML's <tt>&lt;&lt;</tt> operator
258
+ # can be used without additional +nil+ checking)
259
+ # === Parameters
260
+ # * +xml+ - Base Nokogiri::XML object used for building. If omitted, a blank document will be generated.
261
+ # * +node_name_override+ - if present, is used instead of the default element name for this object provided by +define_element_name+
262
+ # ==== Examples
263
+ # obj.write_xml()
264
+ # Creates a new empty +Nokogiri::XML+, populates it with the OOXML structure as described in the respective definition, and returns the resulting +Nokogiri::XML+ object.
265
+ # obj.write_xml(seed_xml)
266
+ # Using the passed-in +Nokogiri+ +xml+ object, creates a new element corresponding to +obj+ according to its definition, along with all its properties and children, and returns the newly created element.
267
+ # obj.write_xml(seed_xml, 'overriden_element_name')
268
+ # Same as above, but uses the passed-in +node_name_override+ as the new element name, instead of its default name set by +define_element_name+.
269
+ def write_xml(xml = nil, node_name_override = nil)
270
+ if xml.nil? then
271
+ seed_xml = Nokogiri::XML('<?xml version = "1.0" standalone ="yes"?>')
272
+ seed_xml.encoding = 'UTF-8'
273
+ result = self.write_xml(seed_xml)
274
+ return result if result == ''
275
+ seed_xml << result
276
+ return seed_xml.to_xml({ :indent => 0, :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML })
277
+ end
278
+
279
+ return '' unless before_write_xml
280
+
281
+ attrs = {}
282
+
283
+ obtain_class_variable(:@@ooxml_attributes).each_pair { |k, v|
284
+ val = self.send(v[:accessor])
285
+
286
+ if val.nil? then
287
+ next unless v[:required]
288
+ val = v[:default]
289
+ end
290
+
291
+ val = val &&
292
+ case v[:attr_type]
293
+ when :bool then val ? '1' : '0'
294
+ when :double then val.to_s.gsub(/\.0*\Z/, '') # Trim trailing zeroes
295
+ else val
296
+ end
297
+
298
+ attrs[k] = val
299
+ }
300
+
301
+ element_text = attrs.delete('_')
302
+ elem = xml.create_element(node_name_override || obtain_class_variable(:@@ooxml_tag_name), attrs, element_text)
303
+
304
+ if @local_namespaces.nil? || @local_namespaces.empty? then # If no local namespaces provided in the original document,
305
+ # use the defaults
306
+ obtain_class_variable(:@@ooxml_namespaces).each_pair { |k, v| elem.add_namespace_definition(v, k) }
307
+ else # otherwise preserve the original ones
308
+ @local_namespaces.each { |ns| elem.add_namespace_definition(ns.prefix, ns.href) }
309
+ end
310
+
311
+ child_nodes = obtain_class_variable(:@@ooxml_child_nodes)
312
+ child_nodes.each_pair { |child_node_name, child_node_params|
313
+ node_obj = get_node_object(child_node_params)
314
+ next if node_obj.nil?
315
+
316
+ if node_obj.respond_to?(:write_xml) && !node_obj.equal?(self) then
317
+ # If child node is either +OOXMLObject+, or +OOXMLContainerObject+ on its first (envelope) pass,
318
+ # serialize that object.
319
+ elem << node_obj.write_xml(xml, child_node_name)
320
+ else
321
+ # If child node is either vanilla +Array+, or +OOXMLContainerObject+ on its seconds (content) pass,
322
+ # serialize its members.
323
+ node_obj.each { |item| elem << item.write_xml(xml, child_node_name) unless item.nil? }
324
+ end
325
+ }
326
+ elem
327
+ end
328
+
329
+ # Prototype method. For sparse collections (+Rows+, +Cells+, etc.) must return index at which this object
330
+ # is expected to reside in the collection. If +nil+ is returned, then object is simply added
331
+ # to the end of the collection.
332
+ def index_in_collection
333
+ nil
334
+ end
335
+
336
+ def get_node_object(child_node_params)
337
+ self.send(child_node_params[:accessor])
338
+ end
339
+ private :get_node_object
340
+
341
+ # Subclass provided filter to perform last-minute operations (cleanup, count, etc.) immediately prior to write,
342
+ # along with option to terminate the actual write if +false+ is returned (for example, to avoid writing
343
+ # the collection's root node if the collection is empty).
344
+ def before_write_xml
345
+ #TODO# This will go away once containers are fully implemented.
346
+ child_nodes = obtain_class_variable(:@@ooxml_child_nodes)
347
+ child_nodes.each_pair { |child_node_name, child_node_params|
348
+ self.count = self.send(child_node_params[:accessor]).size if child_node_params[:is_array] == :with_count
349
+ }
350
+ true
351
+ end
352
+
353
+ end
354
+
355
+ # Parent class for defining OOXML based objects (not unlike Rails' +ActiveRecord+!)
356
+ # Most importantly, provides functionality of parsing such objects from XML,
357
+ # and marshalling them to XML.
358
+ class OOXMLObject
359
+ include OOXMLObjectInstanceMethods
360
+ end
361
+
362
+ # Parent class for OOXML conainer objects (for example,
363
+ # <tt>&lt;fonts&gt;&lt;font&gt;...&lt;/font&gt;&lt;font&gt;...&lt;/font&gt;&lt;/fonts&gt;</tt>
364
+ # that obscures the top-level container, allowing direct access to the contents as +Array+.
365
+ class OOXMLContainerObject < Array
366
+ include OOXMLObjectInstanceMethods
367
+
368
+ def initialize(params = {})
369
+ array_content = params.delete(:_)
370
+ super
371
+ array_content.each_with_index { |v, i| self[i] = v } if array_content
372
+ end
373
+
374
+ def get_node_object(child_node_params)
375
+ if child_node_params[:is_array] then self
376
+ else super
377
+ end
378
+ end
379
+ protected :get_node_object
380
+
381
+ def init_child_nodes(params)
382
+ obtain_class_variable(:@@ooxml_child_nodes).each_value { |v|
383
+ next if v[:is_array] # Only one collection node allowed per OOXMLContainerObject, and it is contained in itself.
384
+ instance_variable_set("@#{v[:accessor]}", params[v[:accessor]])
385
+ }
386
+ end
387
+ protected :init_child_nodes
388
+
389
+ def before_write_xml
390
+ true
391
+ end
392
+
393
+ def inspect
394
+ vars = [ super ]
395
+ vars = self.instance_variables.each { |v| vars << "#{v}=#{instance_variable_get(v).inspect}" }
396
+ "<#{self.class}: #{super} #{vars.join(", ")}>"
397
+ end
398
+
399
+ class << self
400
+ def define_count_attribute
401
+ # Count will be inherited from Array. so no need to define it explicitly.
402
+ define_attribute(:count, :uint, :required => true, :computed => true)
403
+ end
404
+ protected :define_count_attribute
405
+ end
406
+
407
+ end
408
+
409
+ # Extension class providing functionality for top-level OOXML objects that are represented by
410
+ # their own <tt>.xml</tt> files in <tt>.xslx</tt> zip container.
411
+ class OOXMLTopLevelObject < OOXMLObject
412
+ SAVE_ORDER = 500
413
+ ROOT = ::Pathname.new('/')
414
+
415
+ attr_accessor :root
416
+
417
+ # Prototype method. For top-level OOXML object, returns the path at which the current object's XML file
418
+ # is located within the <tt>.xlsx</tt> zip container.
419
+ def xlsx_path
420
+ raise 'Subclass responsebility'
421
+ end
422
+
423
+ # Sets the list of namespaces on this object to be added when writing out XML. Valid only on top-level objects.
424
+ # === Parameters
425
+ # * +namespace_hash+ - Hash of namespaces in the form of <tt>"url" => "prefix"</tt>
426
+ # ==== Examples
427
+ # set_namespaces('http://schemas.openxmlformats.org/spreadsheetml/2006/main' => nil,
428
+ # 'http://schemas.openxmlformats.org/officeDocument/2006/relationships' => 'r')
429
+ def self.set_namespaces(namespace_hash)
430
+ self.class_variable_set(:@@ooxml_namespaces, namespace_hash)
431
+ end
432
+
433
+ # Generates the top-level OOXML object by parsing its XML file from the contents of the <tt>.xslx</tt> container.
434
+ # === Parameters
435
+ # * +zip_file+ - <tt>.xslx</tt> file as <tt>Zip::File</tt> object
436
+ # * +file_path+ - path to the subject file inside the <tt>.xslx</tt> zip archive
437
+ def self.parse_file(zip_file, file_path)
438
+ entry = zip_file.find_entry(RubyXL::from_root(file_path))
439
+ # Accomodate for Nokogiri Java implementation which is incapable of reading from a stream
440
+ entry && (entry.get_input_stream { |f| parse(defined?(JRUBY_VERSION) ? f.read : f) })
441
+ end
442
+
443
+ # Saves the contents of the object as XML to respective location in <tt>.xslx</tt> zip container.
444
+ # === Parameters
445
+ # * +zipfile+ - ::Zip::File to which the resulting XNMML should be added.
446
+ def add_to_zip(zip_stream)
447
+ xml_string = write_xml
448
+ return false if xml_string.empty?
449
+ zip_stream.put_next_entry(RubyXL::from_root(self.xlsx_path))
450
+ zip_stream.write(xml_string)
451
+ true
452
+ end
453
+
454
+ def file_index
455
+ root.rels_hash[self.class].index{ |f| f.equal?(self) }.to_i + 1
456
+ end
457
+
458
+ end
459
+
460
+ end