rubyXL 3.3.22 → 3.4.25

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 (465) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +60 -0
  3. data/.codeclimate.yml +3 -0
  4. data/Gemfile +9 -8
  5. data/Gemfile.lock +124 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.rdoc +54 -18
  8. data/Rakefile +29 -29
  9. data/VERSION +1 -1
  10. data/lib/rubyXL/cell.rb +3 -30
  11. data/lib/rubyXL/convenience_methods/cell.rb +276 -0
  12. data/lib/rubyXL/convenience_methods/color.rb +156 -0
  13. data/lib/rubyXL/convenience_methods/font.rb +63 -0
  14. data/lib/rubyXL/convenience_methods/workbook.rb +141 -0
  15. data/lib/rubyXL/convenience_methods/worksheet.rb +714 -0
  16. data/lib/rubyXL/convenience_methods.rb +5 -1045
  17. data/lib/rubyXL/objects/border.rb +2 -5
  18. data/lib/rubyXL/objects/calculation_chain.rb +4 -4
  19. data/lib/rubyXL/objects/cell_style.rb +9 -11
  20. data/lib/rubyXL/objects/chartsheet.rb +15 -19
  21. data/lib/rubyXL/objects/color.rb +7 -7
  22. data/lib/rubyXL/objects/column_range.rb +10 -13
  23. data/lib/rubyXL/objects/comments.rb +5 -8
  24. data/lib/rubyXL/objects/connection.rb +175 -0
  25. data/lib/rubyXL/objects/container_nodes.rb +3 -7
  26. data/lib/rubyXL/objects/content_types.rb +5 -8
  27. data/lib/rubyXL/objects/data_validation.rb +4 -4
  28. data/lib/rubyXL/objects/document_properties.rb +12 -16
  29. data/lib/rubyXL/objects/extensions.rb +19 -4
  30. data/lib/rubyXL/objects/external_links.rb +30 -8
  31. data/lib/rubyXL/objects/fill.rb +6 -9
  32. data/lib/rubyXL/objects/filters.rb +17 -19
  33. data/lib/rubyXL/objects/font.rb +4 -64
  34. data/lib/rubyXL/objects/formula.rb +4 -6
  35. data/lib/rubyXL/objects/ooxml_object.rb +25 -18
  36. data/lib/rubyXL/objects/query_table.rb +104 -0
  37. data/lib/rubyXL/objects/reference.rb +6 -8
  38. data/lib/rubyXL/objects/relationships.rb +13 -13
  39. data/lib/rubyXL/objects/root.rb +0 -2
  40. data/lib/rubyXL/objects/shared_strings.rb +4 -7
  41. data/lib/rubyXL/objects/sheet_common.rb +5 -7
  42. data/lib/rubyXL/objects/sheet_data.rb +50 -16
  43. data/lib/rubyXL/objects/simple_types.rb +21 -1
  44. data/lib/rubyXL/objects/storage.rb +67 -43
  45. data/lib/rubyXL/objects/stylesheet.rb +22 -29
  46. data/lib/rubyXL/objects/text.rb +12 -14
  47. data/lib/rubyXL/objects/theme.rb +142 -126
  48. data/lib/rubyXL/objects/workbook.rb +172 -64
  49. data/lib/rubyXL/objects/worksheet.rb +143 -128
  50. data/lib/rubyXL/parser.rb +1 -3
  51. data/lib/rubyXL/worksheet.rb +83 -78
  52. data/lib/rubyXL.rb +1 -1
  53. data/rdoc/README_rdoc.html +122 -114
  54. data/rdoc/RubyXL/AExtension.html +21 -60
  55. data/rdoc/RubyXL/AExtensionStorageArea.html +12 -17
  56. data/rdoc/RubyXL/ActiveX.html +154 -0
  57. data/rdoc/RubyXL/ActiveXBinary.html +106 -0
  58. data/rdoc/RubyXL/AdjustHandleList.html +13 -19
  59. data/rdoc/RubyXL/Alignment.html +13 -19
  60. data/rdoc/RubyXL/AlternateContent.html +12 -17
  61. data/rdoc/RubyXL/Authors.html +13 -19
  62. data/rdoc/RubyXL/AutoFilter.html +13 -19
  63. data/rdoc/RubyXL/AutoFilterColumn.html +13 -19
  64. data/rdoc/RubyXL/BinaryImageFile.html +12 -25
  65. data/rdoc/RubyXL/BodyProperties.html +13 -19
  66. data/rdoc/RubyXL/BooleanNode.html +12 -17
  67. data/rdoc/RubyXL/BooleanValue.html +12 -17
  68. data/rdoc/RubyXL/Border.html +25 -84
  69. data/rdoc/RubyXL/BorderEdge.html +20 -52
  70. data/rdoc/RubyXL/Borders.html +19 -39
  71. data/rdoc/RubyXL/Break.html +13 -19
  72. data/rdoc/RubyXL/BreakList.html +13 -19
  73. data/rdoc/RubyXL/CT_AdjPoint2D.html +13 -19
  74. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +13 -19
  75. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +13 -19
  76. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +13 -19
  77. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +13 -19
  78. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +13 -19
  79. data/rdoc/RubyXL/CT_Backdrop.html +13 -19
  80. data/rdoc/RubyXL/CT_Bevel.html +13 -19
  81. data/rdoc/RubyXL/CT_BiLevelEffect.html +13 -19
  82. data/rdoc/RubyXL/CT_BlendEffect.html +13 -19
  83. data/rdoc/RubyXL/CT_Blip.html +13 -19
  84. data/rdoc/RubyXL/CT_BlipFillProperties.html +13 -19
  85. data/rdoc/RubyXL/CT_BlurEffect.html +13 -19
  86. data/rdoc/RubyXL/CT_Camera.html +13 -19
  87. data/rdoc/RubyXL/CT_Color.html +13 -19
  88. data/rdoc/RubyXL/CT_ColorChangeEffect.html +13 -19
  89. data/rdoc/RubyXL/CT_ColorMapping.html +13 -19
  90. data/rdoc/RubyXL/CT_ColorScheme.html +13 -19
  91. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +13 -19
  92. data/rdoc/RubyXL/CT_ConnectionSite.html +13 -19
  93. data/rdoc/RubyXL/CT_ConnectionSiteList.html +13 -19
  94. data/rdoc/RubyXL/CT_DashStop.html +13 -19
  95. data/rdoc/RubyXL/CT_DashStopList.html +13 -19
  96. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +13 -19
  97. data/rdoc/RubyXL/CT_DuotoneEffect.html +13 -19
  98. data/rdoc/RubyXL/CT_EffectContainer.html +13 -19
  99. data/rdoc/RubyXL/CT_EffectList.html +13 -19
  100. data/rdoc/RubyXL/CT_EffectReference.html +13 -19
  101. data/rdoc/RubyXL/CT_EffectStyleItem.html +13 -19
  102. data/rdoc/RubyXL/CT_EffectStyleList.html +13 -19
  103. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +13 -19
  104. data/rdoc/RubyXL/CT_FillEffect.html +13 -19
  105. data/rdoc/RubyXL/CT_FillOverlayEffect.html +13 -19
  106. data/rdoc/RubyXL/CT_FillStyleList.html +13 -19
  107. data/rdoc/RubyXL/CT_FlatText.html +13 -19
  108. data/rdoc/RubyXL/CT_FontCollection.html +13 -19
  109. data/rdoc/RubyXL/CT_FontReference.html +13 -19
  110. data/rdoc/RubyXL/CT_GeomGuideList.html +13 -19
  111. data/rdoc/RubyXL/CT_GlowEffect.html +13 -19
  112. data/rdoc/RubyXL/CT_GradientFillProperties.html +13 -19
  113. data/rdoc/RubyXL/CT_GradientStop.html +13 -19
  114. data/rdoc/RubyXL/CT_GradientStopList.html +13 -19
  115. data/rdoc/RubyXL/CT_HSLEffect.html +13 -19
  116. data/rdoc/RubyXL/CT_HslColor.html +13 -19
  117. data/rdoc/RubyXL/CT_Hyperlink.html +13 -19
  118. data/rdoc/RubyXL/CT_InnerShadowEffect.html +13 -19
  119. data/rdoc/RubyXL/CT_LightRig.html +13 -19
  120. data/rdoc/RubyXL/CT_LineEndProperties.html +13 -19
  121. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +13 -19
  122. data/rdoc/RubyXL/CT_LineProperties.html +13 -19
  123. data/rdoc/RubyXL/CT_LineStyleList.html +13 -19
  124. data/rdoc/RubyXL/CT_LinearShadeProperties.html +13 -19
  125. data/rdoc/RubyXL/CT_LuminanceEffect.html +13 -19
  126. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +13 -19
  127. data/rdoc/RubyXL/CT_OuterShadowEffect.html +13 -19
  128. data/rdoc/RubyXL/CT_Path2D.html +13 -19
  129. data/rdoc/RubyXL/CT_Path2DArcTo.html +13 -19
  130. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +13 -19
  131. data/rdoc/RubyXL/CT_Path2DList.html +13 -19
  132. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +13 -19
  133. data/rdoc/RubyXL/CT_Path2DTo.html +13 -19
  134. data/rdoc/RubyXL/CT_PathShadeProperties.html +13 -19
  135. data/rdoc/RubyXL/CT_PatternFillProperties.html +13 -19
  136. data/rdoc/RubyXL/CT_Point3D.html +13 -19
  137. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +13 -19
  138. data/rdoc/RubyXL/CT_PresetColor.html +13 -19
  139. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +13 -19
  140. data/rdoc/RubyXL/CT_PresetShadowEffect.html +13 -19
  141. data/rdoc/RubyXL/CT_PresetTextShape.html +13 -19
  142. data/rdoc/RubyXL/CT_ReflectionEffect.html +13 -19
  143. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +13 -19
  144. data/rdoc/RubyXL/CT_RelativeRect.html +13 -19
  145. data/rdoc/RubyXL/CT_SRgbColor.html +13 -19
  146. data/rdoc/RubyXL/CT_ScRgbColor.html +13 -19
  147. data/rdoc/RubyXL/CT_Scene3D.html +13 -19
  148. data/rdoc/RubyXL/CT_SchemeColor.html +13 -19
  149. data/rdoc/RubyXL/CT_Shape3D.html +13 -19
  150. data/rdoc/RubyXL/CT_ShapeStyle.html +13 -19
  151. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +13 -19
  152. data/rdoc/RubyXL/CT_SphereCoords.html +13 -19
  153. data/rdoc/RubyXL/CT_StretchInfoProperties.html +13 -19
  154. data/rdoc/RubyXL/CT_StyleMatrix.html +13 -19
  155. data/rdoc/RubyXL/CT_StyleMatrixReference.html +13 -19
  156. data/rdoc/RubyXL/CT_SupplementalFont.html +13 -19
  157. data/rdoc/RubyXL/CT_SystemColor.html +13 -19
  158. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +13 -19
  159. data/rdoc/RubyXL/CT_TextBlipBullet.html +13 -19
  160. data/rdoc/RubyXL/CT_TextCharBullet.html +13 -19
  161. data/rdoc/RubyXL/CT_TextCharacterProperties.html +13 -19
  162. data/rdoc/RubyXL/CT_TextFont.html +13 -19
  163. data/rdoc/RubyXL/CT_TextListStyle.html +13 -19
  164. data/rdoc/RubyXL/CT_TextNormalAutofit.html +13 -19
  165. data/rdoc/RubyXL/CT_TextParagraphProperties.html +13 -19
  166. data/rdoc/RubyXL/CT_TextSpacing.html +13 -19
  167. data/rdoc/RubyXL/CT_TextTabStop.html +13 -19
  168. data/rdoc/RubyXL/CT_TextTabStopList.html +13 -19
  169. data/rdoc/RubyXL/CT_TileInfoProperties.html +13 -19
  170. data/rdoc/RubyXL/CT_TintEffect.html +13 -19
  171. data/rdoc/RubyXL/CT_Transform2D.html +13 -19
  172. data/rdoc/RubyXL/CT_TransformEffect.html +13 -19
  173. data/rdoc/RubyXL/CT_Vector3D.html +13 -19
  174. data/rdoc/RubyXL/CT_XYAdjustHandle.html +13 -19
  175. data/rdoc/RubyXL/CalculationChain.html +17 -45
  176. data/rdoc/RubyXL/CalculationChainCell.html +13 -19
  177. data/rdoc/RubyXL/CalculationProperties.html +13 -19
  178. data/rdoc/RubyXL/Cell.html +145 -205
  179. data/rdoc/RubyXL/CellConvenienceMethods.html +255 -460
  180. data/rdoc/RubyXL/CellExt.html +13 -19
  181. data/rdoc/RubyXL/CellSmartTag.html +13 -19
  182. data/rdoc/RubyXL/CellSmartTagProperty.html +13 -19
  183. data/rdoc/RubyXL/CellSmartTags.html +13 -19
  184. data/rdoc/RubyXL/CellStyle.html +13 -19
  185. data/rdoc/RubyXL/CellStyleXFs.html +19 -39
  186. data/rdoc/RubyXL/CellStyles.html +19 -39
  187. data/rdoc/RubyXL/CellValue.html +18 -38
  188. data/rdoc/RubyXL/CellWatch.html +13 -19
  189. data/rdoc/RubyXL/CellWatches.html +13 -19
  190. data/rdoc/RubyXL/CellXFs.html +20 -42
  191. data/rdoc/RubyXL/ChartColorsFile.html +12 -25
  192. data/rdoc/RubyXL/ChartFile.html +19 -49
  193. data/rdoc/RubyXL/ChartStyleFile.html +12 -25
  194. data/rdoc/RubyXL/ChartUserShapesFile.html +12 -25
  195. data/rdoc/RubyXL/Chartsheet.html +20 -68
  196. data/rdoc/RubyXL/ChartsheetPageSetup.html +13 -19
  197. data/rdoc/RubyXL/ChartsheetProperties.html +13 -19
  198. data/rdoc/RubyXL/ChartsheetProtection.html +13 -19
  199. data/rdoc/RubyXL/ChartsheetView.html +13 -19
  200. data/rdoc/RubyXL/ChartsheetViews.html +13 -19
  201. data/rdoc/RubyXL/Color.html +29 -40
  202. data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +242 -0
  203. data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +279 -0
  204. data/rdoc/RubyXL/ColorConvenienceClasses.html +91 -0
  205. data/rdoc/RubyXL/ColorConvenienceMethods.html +137 -0
  206. data/rdoc/RubyXL/ColorFilter.html +13 -19
  207. data/rdoc/RubyXL/ColorScale.html +13 -19
  208. data/rdoc/RubyXL/ColorSet.html +13 -19
  209. data/rdoc/RubyXL/Colors.html +13 -19
  210. data/rdoc/RubyXL/ColumnRange.html +23 -74
  211. data/rdoc/RubyXL/ColumnRanges.html +24 -83
  212. data/rdoc/RubyXL/Comment.html +13 -19
  213. data/rdoc/RubyXL/CommentList.html +13 -19
  214. data/rdoc/RubyXL/CommentsFile.html +18 -51
  215. data/rdoc/RubyXL/ConditionalFormatValue.html +13 -19
  216. data/rdoc/RubyXL/ConditionalFormatting.html +13 -19
  217. data/rdoc/RubyXL/ConditionalFormattingRule.html +13 -19
  218. data/rdoc/RubyXL/Connection.html +99 -0
  219. data/rdoc/RubyXL/ConnectionTable.html +99 -0
  220. data/rdoc/RubyXL/ConnectionTables.html +99 -0
  221. data/rdoc/RubyXL/ConnectionTextField.html +99 -0
  222. data/rdoc/RubyXL/ConnectionTextFields.html +99 -0
  223. data/rdoc/RubyXL/Connections.html +147 -0
  224. data/rdoc/RubyXL/ContentTypeDefault.html +12 -17
  225. data/rdoc/RubyXL/ContentTypeOverride.html +12 -17
  226. data/rdoc/RubyXL/ContentTypes.html +25 -65
  227. data/rdoc/RubyXL/ControlPropertiesFile.html +14 -22
  228. data/rdoc/RubyXL/CorePropertiesFile.html +35 -171
  229. data/rdoc/RubyXL/CustomColor.html +13 -19
  230. data/rdoc/RubyXL/CustomColorList.html +13 -19
  231. data/rdoc/RubyXL/CustomFilter.html +13 -19
  232. data/rdoc/RubyXL/CustomFilters.html +13 -19
  233. data/rdoc/RubyXL/CustomGeometry.html +13 -19
  234. data/rdoc/RubyXL/CustomProperties.html +13 -19
  235. data/rdoc/RubyXL/CustomPropertiesFile.html +12 -25
  236. data/rdoc/RubyXL/CustomProperty.html +13 -19
  237. data/rdoc/RubyXL/CustomPropertyFile.html +108 -0
  238. data/rdoc/RubyXL/CustomSheetView.html +13 -19
  239. data/rdoc/RubyXL/CustomSheetViews.html +13 -19
  240. data/rdoc/RubyXL/CustomWorkbookView.html +13 -19
  241. data/rdoc/RubyXL/CustomWorkbookViews.html +13 -19
  242. data/rdoc/RubyXL/CustomXMLFile.html +12 -22
  243. data/rdoc/RubyXL/DXF.html +13 -19
  244. data/rdoc/RubyXL/DXFs.html +13 -19
  245. data/rdoc/RubyXL/DataBar.html +13 -19
  246. data/rdoc/RubyXL/DataConsolidate.html +13 -19
  247. data/rdoc/RubyXL/DataConsolidationReference.html +13 -19
  248. data/rdoc/RubyXL/DataConsolidationReferences.html +13 -19
  249. data/rdoc/RubyXL/DataType.html +11 -39
  250. data/rdoc/RubyXL/DataValidation.html +13 -19
  251. data/rdoc/RubyXL/DataValidations.html +13 -19
  252. data/rdoc/RubyXL/DateGroupItem.html +13 -19
  253. data/rdoc/RubyXL/DefinedName.html +13 -19
  254. data/rdoc/RubyXL/DefinedNameExt.html +13 -19
  255. data/rdoc/RubyXL/DefinedNames.html +13 -19
  256. data/rdoc/RubyXL/DefinedNamesExt.html +13 -19
  257. data/rdoc/RubyXL/DocumentPropertiesFile.html +22 -68
  258. data/rdoc/RubyXL/DrawingFile.html +19 -49
  259. data/rdoc/RubyXL/DynamicFilter.html +13 -19
  260. data/rdoc/RubyXL/EmbeddedControl.html +13 -19
  261. data/rdoc/RubyXL/EmbeddedControls.html +13 -19
  262. data/rdoc/RubyXL/Extension.html +13 -19
  263. data/rdoc/RubyXL/ExtensionStorageArea.html +13 -19
  264. data/rdoc/RubyXL/Extents.html +13 -19
  265. data/rdoc/RubyXL/ExternalBook.html +13 -19
  266. data/rdoc/RubyXL/ExternalLinksFile.html +19 -49
  267. data/rdoc/RubyXL/ExternalReference.html +13 -19
  268. data/rdoc/RubyXL/ExternalReferences.html +13 -19
  269. data/rdoc/RubyXL/ExtraColorSchemeList.html +13 -19
  270. data/rdoc/RubyXL/FieldItem.html +13 -19
  271. data/rdoc/RubyXL/FileRecoveryProperties.html +13 -19
  272. data/rdoc/RubyXL/FileSharing.html +13 -19
  273. data/rdoc/RubyXL/FileVersion.html +13 -19
  274. data/rdoc/RubyXL/Fill.html +19 -39
  275. data/rdoc/RubyXL/Fills.html +19 -39
  276. data/rdoc/RubyXL/FilterContainer.html +13 -19
  277. data/rdoc/RubyXL/FloatNode.html +12 -17
  278. data/rdoc/RubyXL/FloatValue.html +12 -17
  279. data/rdoc/RubyXL/Font.html +20 -544
  280. data/rdoc/RubyXL/FontConvenienceMethods.html +414 -0
  281. data/rdoc/RubyXL/FontScheme.html +13 -19
  282. data/rdoc/RubyXL/Fonts.html +19 -39
  283. data/rdoc/RubyXL/Formula.html +13 -19
  284. data/rdoc/RubyXL/FunctionGroup.html +13 -19
  285. data/rdoc/RubyXL/FunctionGroups.html +13 -19
  286. data/rdoc/RubyXL/GenericStorageObject.html +22 -84
  287. data/rdoc/RubyXL/GradientFill.html +13 -19
  288. data/rdoc/RubyXL/HeaderFooterSettings.html +13 -19
  289. data/rdoc/RubyXL/Hyperlink.html +13 -19
  290. data/rdoc/RubyXL/HyperlinkRelFile.html +12 -22
  291. data/rdoc/RubyXL/Hyperlinks.html +13 -19
  292. data/rdoc/RubyXL/IconFilter.html +13 -19
  293. data/rdoc/RubyXL/IconSet.html +13 -19
  294. data/rdoc/RubyXL/IgnoredError.html +13 -19
  295. data/rdoc/RubyXL/IgnoredErrors.html +13 -19
  296. data/rdoc/RubyXL/IndexedColors.html +13 -19
  297. data/rdoc/RubyXL/InputCells.html +13 -19
  298. data/rdoc/RubyXL/IntegerNode.html +12 -17
  299. data/rdoc/RubyXL/IntegerValue.html +12 -17
  300. data/rdoc/RubyXL/LegacyCell.html +14 -66
  301. data/rdoc/RubyXL/LegacyWorksheet.html +40 -100
  302. data/rdoc/RubyXL/MRUColors.html +13 -19
  303. data/rdoc/RubyXL/MacrosFile.html +12 -25
  304. data/rdoc/RubyXL/MergedCell.html +13 -19
  305. data/rdoc/RubyXL/MergedCells.html +13 -19
  306. data/rdoc/RubyXL/NumFmt.html +13 -19
  307. data/rdoc/RubyXL/NumberFormat.html +19 -39
  308. data/rdoc/RubyXL/NumberFormats.html +19 -45
  309. data/rdoc/RubyXL/OLEObject.html +13 -19
  310. data/rdoc/RubyXL/OLEObjectFile.html +12 -25
  311. data/rdoc/RubyXL/OLEObjects.html +13 -19
  312. data/rdoc/RubyXL/OLESize.html +13 -19
  313. data/rdoc/RubyXL/OOXMLContainerObject.html +36 -132
  314. data/rdoc/RubyXL/OOXMLIgnored.html +163 -0
  315. data/rdoc/RubyXL/OOXMLObject.html +15 -25
  316. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +92 -183
  317. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +49 -185
  318. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +48 -200
  319. data/rdoc/RubyXL/OOXMLTopLevelObject.html +37 -133
  320. data/rdoc/RubyXL/OdbcOleDbProperties.html +99 -0
  321. data/rdoc/RubyXL/Offset.html +13 -19
  322. data/rdoc/RubyXL/OlapProperties.html +99 -0
  323. data/rdoc/RubyXL/OleItem.html +99 -0
  324. data/rdoc/RubyXL/OleItems.html +99 -0
  325. data/rdoc/RubyXL/OleLink.html +99 -0
  326. data/rdoc/RubyXL/OutlineProperties.html +13 -19
  327. data/rdoc/RubyXL/PageMargins.html +13 -19
  328. data/rdoc/RubyXL/PageSetup.html +13 -19
  329. data/rdoc/RubyXL/PageSetupProperties.html +13 -19
  330. data/rdoc/RubyXL/Pane.html +13 -19
  331. data/rdoc/RubyXL/Parser.html +23 -56
  332. data/rdoc/RubyXL/PatternFill.html +13 -19
  333. data/rdoc/RubyXL/PhoneticProperties.html +13 -19
  334. data/rdoc/RubyXL/PhoneticRun.html +13 -19
  335. data/rdoc/RubyXL/PivotArea.html +13 -19
  336. data/rdoc/RubyXL/PivotCache.html +13 -19
  337. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +14 -30
  338. data/rdoc/RubyXL/PivotCacheRecordsFile.html +12 -25
  339. data/rdoc/RubyXL/PivotCaches.html +13 -19
  340. data/rdoc/RubyXL/PivotReference.html +13 -19
  341. data/rdoc/RubyXL/PivotReferences.html +13 -19
  342. data/rdoc/RubyXL/PivotTableFile.html +14 -30
  343. data/rdoc/RubyXL/PivotTableSelection.html +13 -19
  344. data/rdoc/RubyXL/PresetGeometry.html +13 -19
  345. data/rdoc/RubyXL/PrintOptions.html +13 -19
  346. data/rdoc/RubyXL/PrinterSettingsFile.html +12 -25
  347. data/rdoc/RubyXL/ProtectedRange.html +13 -19
  348. data/rdoc/RubyXL/ProtectedRanges.html +13 -19
  349. data/rdoc/RubyXL/Protection.html +13 -19
  350. data/rdoc/RubyXL/QueryParameter.html +99 -0
  351. data/rdoc/RubyXL/QueryParameters.html +99 -0
  352. data/rdoc/RubyXL/QueryTable.html +155 -0
  353. data/rdoc/RubyXL/QueryTableDeletedField.html +99 -0
  354. data/rdoc/RubyXL/QueryTableDeletedFields.html +99 -0
  355. data/rdoc/RubyXL/QueryTableField.html +99 -0
  356. data/rdoc/RubyXL/QueryTableFields.html +99 -0
  357. data/rdoc/RubyXL/QueryTableRefresh.html +99 -0
  358. data/rdoc/RubyXL/RID.html +12 -17
  359. data/rdoc/RubyXL/RawOOXML.html +21 -60
  360. data/rdoc/RubyXL/Reference.html +63 -228
  361. data/rdoc/RubyXL/Relationship.html +12 -17
  362. data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +14 -32
  363. data/rdoc/RubyXL/RelationshipSupport.html +26 -120
  364. data/rdoc/RubyXL/RevisionPointer.html +99 -0
  365. data/rdoc/RubyXL/RichText.html +20 -39
  366. data/rdoc/RubyXL/RichTextRun.html +18 -38
  367. data/rdoc/RubyXL/Row.html +53 -152
  368. data/rdoc/RubyXL/RowExt.html +13 -19
  369. data/rdoc/RubyXL/RunProperties.html +13 -19
  370. data/rdoc/RubyXL/Scenario.html +13 -19
  371. data/rdoc/RubyXL/Scenarios.html +13 -19
  372. data/rdoc/RubyXL/Selection.html +19 -39
  373. data/rdoc/RubyXL/ShapeGuide.html +13 -19
  374. data/rdoc/RubyXL/ShapeTextRectangle.html +13 -19
  375. data/rdoc/RubyXL/SharedStringsTable.html +38 -147
  376. data/rdoc/RubyXL/Sheet.html +13 -19
  377. data/rdoc/RubyXL/SheetCalculationProperties.html +13 -19
  378. data/rdoc/RubyXL/SheetData.html +20 -53
  379. data/rdoc/RubyXL/SheetDataExt.html +13 -19
  380. data/rdoc/RubyXL/SheetDataSet.html +13 -19
  381. data/rdoc/RubyXL/SheetMetadata.html +108 -0
  382. data/rdoc/RubyXL/SheetName.html +13 -19
  383. data/rdoc/RubyXL/SheetNames.html +13 -19
  384. data/rdoc/RubyXL/Sheets.html +13 -19
  385. data/rdoc/RubyXL/SlicerCacheFile.html +12 -25
  386. data/rdoc/RubyXL/SlicerFile.html +12 -25
  387. data/rdoc/RubyXL/SmartTagProperties.html +13 -19
  388. data/rdoc/RubyXL/SmartTagType.html +13 -19
  389. data/rdoc/RubyXL/SmartTagTypes.html +13 -19
  390. data/rdoc/RubyXL/SmartTags.html +13 -19
  391. data/rdoc/RubyXL/SortCondition.html +13 -19
  392. data/rdoc/RubyXL/SortState.html +13 -19
  393. data/rdoc/RubyXL/Sqref.html +20 -53
  394. data/rdoc/RubyXL/Stop.html +13 -19
  395. data/rdoc/RubyXL/StringNode.html +12 -17
  396. data/rdoc/RubyXL/StringNodeW3C.html +21 -54
  397. data/rdoc/RubyXL/StringValue.html +12 -17
  398. data/rdoc/RubyXL/Stylesheet.html +35 -117
  399. data/rdoc/RubyXL/TableFile.html +12 -25
  400. data/rdoc/RubyXL/TableParts.html +12 -17
  401. data/rdoc/RubyXL/TableStyle.html +13 -19
  402. data/rdoc/RubyXL/TableStyles.html +13 -19
  403. data/rdoc/RubyXL/Text.html +23 -67
  404. data/rdoc/RubyXL/TextImportSettings.html +99 -0
  405. data/rdoc/RubyXL/Theme.html +57 -62
  406. data/rdoc/RubyXL/ThemeElements.html +13 -19
  407. data/rdoc/RubyXL/ThumbnailFile.html +12 -25
  408. data/rdoc/RubyXL/Top10.html +13 -19
  409. data/rdoc/RubyXL/VMLDrawingFile.html +15 -32
  410. data/rdoc/RubyXL/Variant.html +13 -19
  411. data/rdoc/RubyXL/Vector.html +18 -38
  412. data/rdoc/RubyXL/VectorValue.html +12 -17
  413. data/rdoc/RubyXL/VisualProperties.html +13 -19
  414. data/rdoc/RubyXL/WebPublishObject.html +13 -19
  415. data/rdoc/RubyXL/WebPublishObjects.html +13 -19
  416. data/rdoc/RubyXL/WebPublishingItem.html +13 -19
  417. data/rdoc/RubyXL/WebPublishingItems.html +13 -19
  418. data/rdoc/RubyXL/WebPublishingProperties.html +13 -19
  419. data/rdoc/RubyXL/WebQueryProperties.html +99 -0
  420. data/rdoc/RubyXL/Workbook.html +487 -227
  421. data/rdoc/RubyXL/WorkbookConvenienceMethods.html +163 -871
  422. data/rdoc/RubyXL/WorkbookProperties.html +13 -19
  423. data/rdoc/RubyXL/WorkbookProtection.html +13 -19
  424. data/rdoc/RubyXL/WorkbookRoot.html +28 -114
  425. data/rdoc/RubyXL/WorkbookView.html +13 -19
  426. data/rdoc/RubyXL/WorkbookViews.html +13 -19
  427. data/rdoc/RubyXL/Worksheet.html +93 -121
  428. data/rdoc/RubyXL/WorksheetConvenienceMethods.html +299 -1109
  429. data/rdoc/RubyXL/WorksheetDimensions.html +13 -19
  430. data/rdoc/RubyXL/WorksheetFormatProperties.html +12 -17
  431. data/rdoc/RubyXL/WorksheetProperties.html +13 -19
  432. data/rdoc/RubyXL/WorksheetProtection.html +13 -19
  433. data/rdoc/RubyXL/WorksheetView.html +13 -19
  434. data/rdoc/RubyXL/WorksheetViews.html +13 -19
  435. data/rdoc/RubyXL/XF.html +13 -19
  436. data/rdoc/RubyXL.html +41 -296
  437. data/rdoc/created.rid +45 -38
  438. data/rdoc/css/fonts.css +6 -6
  439. data/rdoc/css/rdoc.css +55 -6
  440. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  441. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  442. data/rdoc/index.html +44 -363
  443. data/rdoc/js/darkfish.js +23 -100
  444. data/rdoc/js/navigation.js +4 -41
  445. data/rdoc/js/navigation.js.gz +0 -0
  446. data/rdoc/js/search.js +32 -31
  447. data/rdoc/js/search_index.js +1 -1
  448. data/rdoc/js/search_index.js.gz +0 -0
  449. data/rdoc/js/searcher.js +7 -6
  450. data/rdoc/js/searcher.js.gz +0 -0
  451. data/rdoc/table_of_contents.html +347 -75
  452. data/rubyXL.gemspec +78 -43
  453. data/spec/lib/cell_spec.rb +115 -4
  454. data/spec/lib/color_spec.rb +2 -1
  455. data/spec/lib/parser_spec.rb +24 -27
  456. data/spec/lib/reference_spec.rb +9 -3
  457. data/spec/lib/rgb_color_spec.rb +27 -0
  458. data/spec/lib/stylesheet_spec.rb +8 -11
  459. data/spec/lib/text_spec.rb +8 -4
  460. data/spec/lib/workbook_spec.rb +26 -5
  461. data/spec/lib/worksheet_spec.rb +873 -479
  462. data/spec/spec_helper.rb +2 -0
  463. data/test/test_parse_write.rb +15 -15
  464. metadata +65 -10
  465. data/rdoc/js/jquery.js +0 -4
@@ -1,1045 +1,5 @@
1
- module RubyXL
2
-
3
- module WorkbookConvenienceMethods
4
- SHEET_NAME_TEMPLATE = 'Sheet%d'
5
-
6
- # Finds worksheet by its name or numerical index
7
- def [](ind)
8
- case ind
9
- when Integer then worksheets[ind]
10
- when String then worksheets.find { |ws| ws.sheet_name == ind }
11
- end
12
- end
13
-
14
- # Create new simple worksheet and add it to the workbook worksheets
15
- #
16
- # @param [String] The name for the new worksheet
17
- def add_worksheet(name = nil)
18
- if name.nil? then
19
- n = 0
20
-
21
- begin
22
- name = SHEET_NAME_TEMPLATE % (n += 1)
23
- end until self[name].nil?
24
- end
25
-
26
- new_worksheet = Worksheet.new(:workbook => self, :sheet_name => name)
27
- worksheets << new_worksheet
28
- new_worksheet
29
- end
30
-
31
- def each
32
- worksheets.each{ |i| yield i }
33
- end
34
-
35
- def date1904
36
- workbook_properties && workbook_properties.date1904
37
- end
38
-
39
- def date1904=(v)
40
- self.workbook_properties ||= RubyXL::WorkbookProperties.new
41
- workbook_properties.date1904 = v
42
- end
43
-
44
- def company
45
- root.document_properties.company && root.document_properties.company.value
46
- end
47
-
48
- def company=(v)
49
- root.document_properties.company ||= StringNode.new
50
- root.document_properties.company.value = v
51
- end
52
-
53
- def application
54
- root.document_properties.application && root.document_properties.application.value
55
- end
56
-
57
- def application=(v)
58
- root.document_properties.application ||= StringNode.new
59
- root.document_properties.application.value = v
60
- end
61
-
62
- def appversion
63
- root.document_properties.app_version && root.document_properties.app_version.value
64
- end
65
-
66
- def appversion=(v)
67
- root.document_properties.app_version ||= StringNode.new
68
- root.document_properties.app_version.value = v
69
- end
70
-
71
- def creator
72
- root.core_properties.creator
73
- end
74
-
75
- def creator=(v)
76
- root.core_properties.creator = v
77
- end
78
-
79
- def modifier
80
- root.core_properties.modifier
81
- end
82
-
83
- def modifier=(v)
84
- root.core_properties.modifier = v
85
- end
86
-
87
- def created_at
88
- root.core_properties.created_at
89
- end
90
-
91
- def created_at=(v)
92
- root.core_properties.created_at = v
93
- end
94
-
95
- def modified_at
96
- root.core_properties.modified_at
97
- end
98
-
99
- def modified_at=(v)
100
- root.core_properties.modified_at = v
101
- end
102
-
103
- def cell_xfs # Stylesheet should be pre-filled with defaults on initialize()
104
- stylesheet.cell_xfs
105
- end
106
-
107
- def fonts # Stylesheet should be pre-filled with defaults on initialize()
108
- stylesheet.fonts
109
- end
110
-
111
- def fills # Stylesheet should be pre-filled with defaults on initialize()
112
- stylesheet.fills
113
- end
114
-
115
- def borders # Stylesheet should be pre-filled with defaults on initialize()
116
- stylesheet.borders
117
- end
118
-
119
- def get_fill_color(xf)
120
- fill = fills[xf.fill_id]
121
- pattern = fill && fill.pattern_fill
122
- color = pattern && pattern.fg_color
123
- color && color.rgb || 'ffffff'
124
- end
125
-
126
- def register_new_fill(new_fill, old_xf)
127
- new_xf = old_xf.dup
128
- new_xf.apply_fill = true
129
- new_xf.fill_id = fills.find_index { |x| x == new_fill } # Reuse existing fill, if it exists
130
- new_xf.fill_id ||= fills.size # If this fill has never existed before, add it to collection.
131
- fills[new_xf.fill_id] = new_fill
132
- new_xf
133
- end
134
-
135
- def register_new_font(new_font, old_xf)
136
- new_xf = old_xf.dup
137
- new_xf.font_id = fonts.find_index { |x| x == new_font } # Reuse existing font, if it exists
138
- new_xf.font_id ||= fonts.size # If this font has never existed before, add it to collection.
139
- fonts[new_xf.font_id] = new_font
140
- new_xf.apply_font = true
141
- new_xf
142
- end
143
-
144
- def register_new_xf(new_xf)
145
- new_xf_id = cell_xfs.find_index { |xf| xf == new_xf } # Reuse existing XF, if it exists
146
- new_xf_id ||= cell_xfs.size # If this XF has never existed before, add it to collection.
147
- cell_xfs[new_xf_id] = new_xf
148
- new_xf_id
149
- end
150
-
151
- def modify_alignment(style_index, &block)
152
- xf = cell_xfs[style_index || 0].dup
153
- xf.alignment ||= RubyXL::Alignment.new
154
- yield(xf.alignment)
155
- xf.apply_alignment = true
156
-
157
- register_new_xf(xf)
158
- end
159
-
160
- def modify_fill(style_index, rgb)
161
- xf = cell_xfs[style_index || 0].dup
162
- new_fill = RubyXL::Fill.new(:pattern_fill =>
163
- RubyXL::PatternFill.new(:pattern_type => 'solid',
164
- :fg_color => RubyXL::Color.new(:rgb => rgb)))
165
- register_new_xf(register_new_fill(new_fill, xf))
166
- end
167
-
168
- def modify_border(style_index, direction, weight)
169
- xf = cell_xfs[style_index || 0].dup
170
- new_border = borders[xf.border_id || 0].dup
171
- new_border.set_edge_style(direction, weight)
172
-
173
- xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
174
- xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
175
- borders[xf.border_id] = new_border
176
- xf.apply_border = true
177
-
178
- register_new_xf(xf)
179
- end
180
-
181
- def modify_border_color(style_index, direction, color)
182
- xf = cell_xfs[style_index || 0].dup
183
- new_border = borders[xf.border_id || 0].dup
184
- new_border.set_edge_color(direction, color)
185
-
186
- xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
187
- xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
188
- borders[xf.border_id] = new_border
189
- xf.apply_border = true
190
-
191
- register_new_xf(xf)
192
- end
193
- end
194
-
195
-
196
- module WorksheetConvenienceMethods
197
- NAME = 0
198
- SIZE = 1
199
- COLOR = 2
200
- ITALICS = 3
201
- BOLD = 4
202
- UNDERLINE = 5
203
- STRIKETHROUGH = 6
204
-
205
- def insert_cell(row = 0, col = 0, data = nil, formula = nil, shift = nil)
206
- validate_workbook
207
- ensure_cell_exists(row, col)
208
-
209
- case shift
210
- when nil then # No shifting at all
211
- when :right then
212
- sheet_data.rows[row].insert_cell_shift_right(nil, col)
213
- when :down then
214
- add_row(sheet_data.size, :cells => Array.new(sheet_data.rows[row].size))
215
- (sheet_data.size - 1).downto(row+1) { |index|
216
- sheet_data.rows[index].cells[col] = sheet_data.rows[index-1].cells[col]
217
- }
218
- else
219
- raise 'invalid shift option'
220
- end
221
-
222
- return add_cell(row, col, data, formula)
223
- end
224
-
225
- # by default, only sets cell to nil
226
- # if :left is specified, method will shift row contents to the right of the deleted cell to the left
227
- # if :up is specified, method will shift column contents below the deleted cell upward
228
- def delete_cell(row_index = 0, column_index=0, shift=nil)
229
- validate_workbook
230
- validate_nonnegative(row_index)
231
- validate_nonnegative(column_index)
232
-
233
- row = sheet_data[row_index]
234
- old_cell = row && row[column_index]
235
-
236
- case shift
237
- when nil then
238
- row.cells[column_index] = nil if row
239
- when :left then
240
- row.delete_cell_shift_left(column_index) if row
241
- when :up then
242
- (row_index...(sheet_data.size - 1)).each { |index|
243
- c = sheet_data.rows[index].cells[column_index] = sheet_data.rows[index + 1].cells[column_index]
244
- c.row -= 1 if c.is_a?(Cell)
245
- }
246
- else
247
- raise 'invalid shift option'
248
- end
249
-
250
- return old_cell
251
- end
252
-
253
- # Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!)
254
- # NOTE: use of this method will break formulas which reference cells which are being "pushed down"
255
- def insert_row(row_index = 0)
256
- validate_workbook
257
- ensure_cell_exists(row_index)
258
-
259
- old_row = new_cells = nil
260
-
261
- if row_index > 0 then
262
- old_row = sheet_data.rows[row_index - 1]
263
- if old_row then
264
- new_cells = old_row.cells.collect { |c|
265
- if c.nil? then nil
266
- else nc = RubyXL::Cell.new(:style_index => c.style_index)
267
- nc.worksheet = self
268
- nc
269
- end
270
- }
271
- end
272
- end
273
-
274
- row0 = sheet_data.rows[0]
275
- new_cells ||= Array.new((row0 && row0.cells.size) || 0)
276
-
277
- sheet_data.rows.insert(row_index, nil)
278
- new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
279
-
280
- # Update row values for all rows below
281
- row_index.upto(sheet_data.rows.size - 1) { |r|
282
- row = sheet_data.rows[r]
283
- next if row.nil?
284
- row.cells.each_with_index { |cell, c|
285
- next if cell.nil?
286
- cell.r = RubyXL::Reference.new(r, c)
287
- }
288
- }
289
-
290
- return new_row
291
- end
292
-
293
- def delete_row(row_index=0)
294
- validate_workbook
295
- validate_nonnegative(row_index)
296
-
297
- deleted = sheet_data.rows.delete_at(row_index)
298
-
299
- # Update row number of each cell
300
- row_index.upto(sheet_data.size - 1) { |index|
301
- row = sheet_data[index]
302
- row && row.cells.each{ |c| c.row -= 1 unless c.nil? }
303
- }
304
-
305
- return deleted
306
- end
307
-
308
- # Inserts column at +column_index+, pushes everything right, takes styles from column to left
309
- # NOTE: use of this method will break formulas which reference cells which are being "pushed right"
310
- def insert_column(column_index = 0)
311
- validate_workbook
312
- ensure_cell_exists(0, column_index)
313
-
314
- old_range = cols.get_range(column_index)
315
-
316
- #go through each cell in column
317
- sheet_data.rows.each_with_index { |row, row_index|
318
- old_cell = row[column_index]
319
- c = nil
320
-
321
- if old_cell && old_cell.style_index != 0 &&
322
- old_range && old_range.style_index != old_cell.style_index then
323
-
324
- c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
325
- :row => row_index, :column => column_index,
326
- :datatype => RubyXL::DataType::SHARED_STRING)
327
- end
328
-
329
- row.insert_cell_shift_right(c, column_index)
330
- }
331
-
332
- cols.insert_column(column_index)
333
-
334
- # TODO: update column numbers
335
- end
336
-
337
- def delete_column(column_index = 0)
338
- validate_workbook
339
- validate_nonnegative(column_index)
340
-
341
- # Delete column
342
- sheet_data.rows.each { |row| row.cells.delete_at(column_index) }
343
-
344
- # Update column numbers for cells to the right of the deleted column
345
- sheet_data.rows.each_with_index { |row, row_index|
346
- row.cells.each_with_index { |c, ci|
347
- c.column = ci if c.is_a?(Cell)
348
- }
349
- }
350
-
351
- cols.each { |range| range.delete_column(column_index) }
352
- end
353
-
354
- def get_row_style(row_index)
355
- row = sheet_data.rows[row_index]
356
- (row && row.style_index) || 0
357
- end
358
-
359
- def get_row_fill(row = 0)
360
- (row = sheet_data.rows[row]) && row.get_fill_color
361
- end
362
-
363
- def get_row_font_name(row = 0)
364
- (font = row_font(row)) && font.get_name
365
- end
366
-
367
- def get_row_font_size(row = 0)
368
- (font = row_font(row)) && font.get_size
369
- end
370
-
371
- def get_row_font_color(row = 0)
372
- font = row_font(row)
373
- color = font && font.color
374
- color && (color.rgb || '000000')
375
- end
376
-
377
- def is_row_italicized(row = 0)
378
- (font = row_font(row)) && font.is_italic
379
- end
380
-
381
- def is_row_bolded(row = 0)
382
- (font = row_font(row)) && font.is_bold
383
- end
384
-
385
- def is_row_underlined(row = 0)
386
- (font = row_font(row)) && font.is_underlined
387
- end
388
-
389
- def is_row_struckthrough(row = 0)
390
- (font = row_font(row)) && font.is_strikethrough
391
- end
392
-
393
- def get_row_height(row = 0)
394
- validate_workbook
395
- validate_nonnegative(row)
396
- row = sheet_data.rows[row]
397
- row && row.ht || RubyXL::Row::DEFAULT_HEIGHT
398
- end
399
-
400
- def get_row_border(row, border_direction)
401
- validate_workbook
402
-
403
- border = @workbook.borders[get_row_xf(row).border_id]
404
- border && border.get_edge_style(border_direction)
405
- end
406
-
407
- def get_row_border_color(row, border_direction)
408
- validate_workbook
409
-
410
- border = @workbook.borders[get_row_xf(row).border_id]
411
- border && border.get_edge_color(border_direction)
412
- end
413
-
414
- def row_font(row)
415
- (row = sheet_data.rows[row]) && row.get_font
416
- end
417
-
418
- def get_row_alignment(row, is_horizontal)
419
- validate_workbook
420
-
421
- xf_obj = get_row_xf(row)
422
- return nil if xf_obj.alignment.nil?
423
-
424
- if is_horizontal then return xf_obj.alignment.horizontal
425
- else return xf_obj.alignment.vertical
426
- end
427
- end
428
-
429
- def get_cols_style_index(column_index)
430
- validate_nonnegative(column_index)
431
- range = cols.locate_range(column_index)
432
- (range && range.style_index) || 0
433
- end
434
-
435
- def get_column_font_name(col = 0)
436
- font = column_font(col)
437
- font && font.get_name
438
- end
439
-
440
- def get_column_font_size(col = 0)
441
- font = column_font(col)
442
- font && font.get_size
443
- end
444
-
445
- def get_column_font_color(col = 0)
446
- font = column_font(col)
447
- font && (font.get_rgb_color || '000000')
448
- end
449
-
450
- def is_column_italicized(col = 0)
451
- font = column_font(col)
452
- font && font.is_italic
453
- end
454
-
455
- def is_column_bolded(col = 0)
456
- font = column_font(col)
457
- font && font.is_bold
458
- end
459
-
460
- def is_column_underlined(col = 0)
461
- font = column_font(col)
462
- font && font.is_underlined
463
- end
464
-
465
- def is_column_struckthrough(col = 0)
466
- font = column_font(col)
467
- font && font.is_strikethrough
468
- end
469
-
470
- # Get raw column width value as stored in the file
471
- def get_column_width_raw(column_index = 0)
472
- validate_workbook
473
- validate_nonnegative(column_index)
474
-
475
- range = cols.locate_range(column_index)
476
- range && range.width
477
- end
478
-
479
- # Get column width measured in number of digits, as per
480
- # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
481
- def get_column_width(column_index = 0)
482
- width = get_column_width_raw(column_index)
483
- return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
484
- (width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
485
- end
486
-
487
- # Set raw column width value
488
- def change_column_width_raw(column_index, width)
489
- validate_workbook
490
- ensure_cell_exists(0, column_index)
491
- range = cols.get_range(column_index)
492
- range.width = width
493
- range.custom_width = true
494
- end
495
-
496
- # Get column width measured in number of digits, as per
497
- # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
498
- def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
499
- change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
500
- end
501
-
502
- # Helper method to get the style index for a column
503
- def get_col_style(column_index)
504
- range = cols.locate_range(column_index)
505
- (range && range.style_index) || 0
506
- end
507
-
508
- def get_column_fill(col=0)
509
- validate_workbook
510
- validate_nonnegative(col)
511
-
512
- @workbook.get_fill_color(get_col_xf(col))
513
- end
514
-
515
- def change_column_fill(column_index, color_code = 'ffffff')
516
- validate_workbook
517
- RubyXL::Color.validate_color(color_code)
518
- ensure_cell_exists(0, column_index)
519
-
520
- cols.get_range(column_index).style_index = @workbook.modify_fill(get_col_style(column_index), color_code)
521
-
522
- sheet_data.rows.each { |row|
523
- c = row[column_index]
524
- c.change_fill(color_code) if c
525
- }
526
- end
527
-
528
- def get_column_border(col, border_direction)
529
- validate_workbook
530
-
531
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
532
- border = @workbook.borders[xf.border_id]
533
- border && border.get_edge_style(border_direction)
534
- end
535
-
536
- def get_column_border_color(col, border_direction)
537
- validate_workbook
538
-
539
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
540
- border = @workbook.borders[xf.border_id]
541
- border && border.get_edge_color(border_direction)
542
- end
543
-
544
- def column_font(col)
545
- validate_workbook
546
-
547
- @workbook.fonts[@workbook.cell_xfs[get_cols_style_index(col)].font_id]
548
- end
549
-
550
- def get_column_alignment(col, type)
551
- validate_workbook
552
-
553
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
554
- xf.alignment && xf.alignment.send(type)
555
- end
556
-
557
- def change_row_horizontal_alignment(row = 0, alignment = 'center')
558
- validate_workbook
559
- validate_nonnegative(row)
560
- change_row_alignment(row) { |a| a.horizontal = alignment }
561
- end
562
-
563
- def change_row_vertical_alignment(row = 0, alignment = 'center')
564
- validate_workbook
565
- validate_nonnegative(row)
566
- change_row_alignment(row) { |a| a.vertical = alignment }
567
- end
568
-
569
- def change_row_border(row, direction, weight)
570
- validate_workbook
571
- ensure_cell_exists(row)
572
-
573
- sheet_data.rows[row].style_index = @workbook.modify_border(get_row_style(row), direction, weight)
574
-
575
- sheet_data[row].cells.each { |c|
576
- c.change_border(direction, weight) unless c.nil?
577
- }
578
- end
579
-
580
- def change_row_border_color(row, direction, color = '000000')
581
- validate_workbook
582
- ensure_cell_exists(row)
583
- Color.validate_color(color)
584
-
585
- sheet_data.rows[row].style_index = @workbook.modify_border_color(get_row_style(row), direction, color)
586
-
587
- sheet_data[row].cells.each { |c|
588
- c.change_border_color(direction, color) unless c.nil?
589
- }
590
- end
591
-
592
- def change_row_fill(row_index = 0, rgb = 'ffffff')
593
- validate_workbook
594
- ensure_cell_exists(row_index)
595
- Color.validate_color(rgb)
596
-
597
- sheet_data.rows[row_index].style_index = @workbook.modify_fill(get_row_style(row_index), rgb)
598
- sheet_data[row_index].cells.each { |c| c.change_fill(rgb) unless c.nil? }
599
- end
600
-
601
- # Helper method to update the row styles array
602
- # change_type - NAME or SIZE or COLOR etc
603
- # main method to change font, called from each separate font mutator method
604
- def change_row_font(row_index, change_type, arg, font)
605
- validate_workbook
606
- ensure_cell_exists(row_index)
607
-
608
- xf = workbook.register_new_font(font, get_row_xf(row_index))
609
- row = sheet_data[row_index]
610
- row.style_index = workbook.register_new_xf(xf)
611
- row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
612
- end
613
-
614
- def change_row_font_name(row = 0, font_name = 'Verdana')
615
- ensure_cell_exists(row)
616
- font = row_font(row).dup
617
- font.set_name(font_name)
618
- change_row_font(row, Worksheet::NAME, font_name, font)
619
- end
620
-
621
- def change_row_font_size(row = 0, font_size=10)
622
- ensure_cell_exists(row)
623
- font = row_font(row).dup
624
- font.set_size(font_size)
625
- change_row_font(row, Worksheet::SIZE, font_size, font)
626
- end
627
-
628
- def change_row_font_color(row = 0, font_color = '000000')
629
- ensure_cell_exists(row)
630
- Color.validate_color(font_color)
631
- font = row_font(row).dup
632
- font.set_rgb_color(font_color)
633
- change_row_font(row, Worksheet::COLOR, font_color, font)
634
- end
635
-
636
- def change_row_italics(row = 0, italicized = false)
637
- ensure_cell_exists(row)
638
- font = row_font(row).dup
639
- font.set_italic(italicized)
640
- change_row_font(row, Worksheet::ITALICS, italicized, font)
641
- end
642
-
643
- def change_row_bold(row = 0, bolded = false)
644
- ensure_cell_exists(row)
645
- font = row_font(row).dup
646
- font.set_bold(bolded)
647
- change_row_font(row, Worksheet::BOLD, bolded, font)
648
- end
649
-
650
- def change_row_underline(row = 0, underlined=false)
651
- ensure_cell_exists(row)
652
- font = row_font(row).dup
653
- font.set_underline(underlined)
654
- change_row_font(row, Worksheet::UNDERLINE, underlined, font)
655
- end
656
-
657
- def change_row_strikethrough(row = 0, struckthrough=false)
658
- ensure_cell_exists(row)
659
- font = row_font(row).dup
660
- font.set_strikethrough(struckthrough)
661
- change_row_font(row, Worksheet::STRIKETHROUGH, struckthrough, font)
662
- end
663
-
664
- def change_row_height(row = 0, height = 10)
665
- validate_workbook
666
- ensure_cell_exists(row)
667
-
668
- c = sheet_data.rows[row]
669
- c.ht = height
670
- c.custom_height = true
671
- end
672
-
673
- # Helper method to update the fonts and cell styles array
674
- # main method to change font, called from each separate font mutator method
675
- def change_column_font(column_index, change_type, arg, font, xf)
676
- validate_workbook
677
- ensure_cell_exists(0, column_index)
678
-
679
- xf = workbook.register_new_font(font, xf)
680
- cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
681
-
682
- sheet_data.rows.each { |row|
683
- c = row && row[column_index]
684
- c.font_switch(change_type, arg) unless c.nil?
685
- }
686
- end
687
-
688
- def change_column_font_name(column_index = 0, font_name = 'Verdana')
689
- xf = get_col_xf(column_index)
690
- font = @workbook.fonts[xf.font_id].dup
691
- font.set_name(font_name)
692
- change_column_font(column_index, Worksheet::NAME, font_name, font, xf)
693
- end
694
-
695
- def change_column_font_size(column_index, font_size=10)
696
- xf = get_col_xf(column_index)
697
- font = @workbook.fonts[xf.font_id].dup
698
- font.set_size(font_size)
699
- change_column_font(column_index, Worksheet::SIZE, font_size, font, xf)
700
- end
701
-
702
- def change_column_font_color(column_index, font_color='000000')
703
- Color.validate_color(font_color)
704
-
705
- xf = get_col_xf(column_index)
706
- font = @workbook.fonts[xf.font_id].dup
707
- font.set_rgb_color(font_color)
708
- change_column_font(column_index, Worksheet::COLOR, font_color, font, xf)
709
- end
710
-
711
- def change_column_italics(column_index, italicized = false)
712
- xf = get_col_xf(column_index)
713
- font = @workbook.fonts[xf.font_id].dup
714
- font.set_italic(italicized)
715
- change_column_font(column_index, Worksheet::ITALICS, italicized, font, xf)
716
- end
717
-
718
- def change_column_bold(column_index, bolded = false)
719
- xf = get_col_xf(column_index)
720
- font = @workbook.fonts[xf.font_id].dup
721
- font.set_bold(bolded)
722
- change_column_font(column_index, Worksheet::BOLD, bolded, font, xf)
723
- end
724
-
725
- def change_column_underline(column_index, underlined = false)
726
- xf = get_col_xf(column_index)
727
- font = @workbook.fonts[xf.font_id].dup
728
- font.set_underline(underlined)
729
- change_column_font(column_index, Worksheet::UNDERLINE, underlined, font, xf)
730
- end
731
-
732
- def change_column_strikethrough(column_index, struckthrough=false)
733
- xf = get_col_xf(column_index)
734
- font = @workbook.fonts[xf.font_id].dup
735
- font.set_strikethrough(struckthrough)
736
- change_column_font(column_index, Worksheet::STRIKETHROUGH, struckthrough, font, xf)
737
- end
738
-
739
- def change_column_horizontal_alignment(column_index, alignment = 'center')
740
- change_column_alignment(column_index) { |a| a.horizontal = alignment }
741
- end
742
-
743
- def change_column_vertical_alignment(column_index, alignment = 'center')
744
- change_column_alignment(column_index) { |a| a.vertical = alignment }
745
- end
746
-
747
- def change_column_border(column_index, direction, weight)
748
- validate_workbook
749
- ensure_cell_exists(0, column_index)
750
-
751
- cols.get_range(column_index).style_index = @workbook.modify_border(get_col_style(column_index), direction, weight)
752
-
753
- sheet_data.rows.each { |row|
754
- c = row.cells[column_index]
755
- c.change_border(direction, weight) unless c.nil?
756
- }
757
- end
758
-
759
- def change_column_border_color(column_index, direction, color)
760
- validate_workbook
761
- ensure_cell_exists(0, column_index)
762
- Color.validate_color(color)
763
-
764
- cols.get_range(column_index).style_index = @workbook.modify_border_color(get_col_style(column_index), direction, color)
765
-
766
- sheet_data.rows.each { |row|
767
- c = row.cells[column_index]
768
- c.change_border_color(direction, color) unless c.nil?
769
- }
770
- end
771
-
772
- def change_row_alignment(row, &block)
773
- validate_workbook
774
- validate_nonnegative(row)
775
- ensure_cell_exists(row)
776
-
777
- sheet_data.rows[row].style_index = @workbook.modify_alignment(get_row_style(row), &block)
778
-
779
- sheet_data[row].cells.each { |c|
780
- next if c.nil?
781
- c.style_index = @workbook.modify_alignment(c.style_index, &block)
782
- }
783
- end
784
-
785
- def change_column_alignment(column_index, &block)
786
- validate_workbook
787
- ensure_cell_exists(0, column_index)
788
-
789
- cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
790
- # Excel gets confused if width is not explicitly set for a column that had alignment changes
791
- change_column_width(column_index) if get_column_width_raw(column_index).nil?
792
-
793
- sheet_data.rows.each { |row|
794
- c = row[column_index]
795
- next if c.nil?
796
- c.style_index = @workbook.modify_alignment(c.style_index, &block)
797
- }
798
- end
799
-
800
- # Merges cells within a rectangular area
801
- def merge_cells(start_row, start_col, end_row, end_col)
802
- validate_workbook
803
-
804
- self.merged_cells ||= RubyXL::MergedCells.new
805
- # TODO: add validation to make sure ranges are not intersecting with existing ones
806
- merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
807
- end
808
- end
809
-
810
- module CellConvenienceMethods
811
-
812
- def change_contents(data, formula_expression = nil)
813
- validate_worksheet
814
-
815
- if formula_expression then
816
- self.datatype = nil
817
- self.formula = RubyXL::Formula.new(:expression => formula_expression)
818
- else
819
- self.datatype = case data
820
- when Date, Numeric then nil
821
- else RubyXL::DataType::RAW_STRING
822
- end
823
- end
824
-
825
- data = workbook.date_to_num(data) if data.is_a?(Date)
826
-
827
- self.raw_value = data
828
- end
829
-
830
- def get_border(direction)
831
- validate_worksheet
832
- get_cell_border.get_edge_style(direction)
833
- end
834
-
835
- def get_border_color(direction)
836
- validate_worksheet
837
- get_cell_border.get_edge_color(direction)
838
- end
839
-
840
- def change_horizontal_alignment(alignment = 'center')
841
- validate_worksheet
842
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.horizontal = alignment }
843
- end
844
-
845
- def change_vertical_alignment(alignment = 'center')
846
- validate_worksheet
847
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.vertical = alignment }
848
- end
849
-
850
- def change_text_wrap(wrap = false)
851
- validate_worksheet
852
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.wrap_text = wrap }
853
- end
854
-
855
- def change_border(direction, weight)
856
- validate_worksheet
857
- self.style_index = workbook.modify_border(self.style_index, direction, weight)
858
- end
859
-
860
- def change_border_color(direction, color)
861
- validate_worksheet
862
- Color.validate_color(color)
863
- self.style_index = workbook.modify_border_color(self.style_index, direction, color)
864
- end
865
-
866
- def is_italicized()
867
- validate_worksheet
868
- get_cell_font.is_italic
869
- end
870
-
871
- def is_bolded()
872
- validate_worksheet
873
- get_cell_font.is_bold
874
- end
875
-
876
- def is_underlined()
877
- validate_worksheet
878
- get_cell_font.is_underlined
879
- end
880
-
881
- def is_struckthrough()
882
- validate_worksheet
883
- get_cell_font.is_strikethrough
884
- end
885
-
886
- def font_name()
887
- validate_worksheet
888
- get_cell_font.get_name
889
- end
890
-
891
- def font_size()
892
- validate_worksheet
893
- get_cell_font.get_size
894
- end
895
-
896
- def font_color()
897
- validate_worksheet
898
- get_cell_font.get_rgb_color || '000000'
899
- end
900
-
901
- def fill_color()
902
- validate_worksheet
903
- return workbook.get_fill_color(get_cell_xf)
904
- end
905
-
906
- def horizontal_alignment()
907
- validate_worksheet
908
- xf_obj = get_cell_xf
909
- return nil if xf_obj.alignment.nil?
910
- xf_obj.alignment.horizontal
911
- end
912
-
913
- def vertical_alignment()
914
- validate_worksheet
915
- xf_obj = get_cell_xf
916
- return nil if xf_obj.alignment.nil?
917
- xf_obj.alignment.vertical
918
- end
919
-
920
- def text_wrap()
921
- validate_worksheet
922
- xf_obj = get_cell_xf
923
- return nil if xf_obj.alignment.nil?
924
- xf_obj.alignment.wrap_text
925
- end
926
-
927
- def set_number_format(format_code)
928
- new_xf = get_cell_xf.dup
929
- new_xf.num_fmt_id = workbook.stylesheet.register_number_format(format_code)
930
- new_xf.apply_number_format = true
931
- self.style_index = workbook.register_new_xf(new_xf)
932
- end
933
-
934
- # Changes fill color of cell
935
- def change_fill(rgb = 'ffffff')
936
- validate_worksheet
937
- Color.validate_color(rgb)
938
- self.style_index = workbook.modify_fill(self.style_index, rgb)
939
- end
940
-
941
- # Changes font name of cell
942
- def change_font_name(new_font_name = 'Verdana')
943
- validate_worksheet
944
-
945
- font = get_cell_font.dup
946
- font.set_name(new_font_name)
947
- update_font_references(font)
948
- end
949
-
950
- # Changes font size of cell
951
- def change_font_size(font_size = 10)
952
- validate_worksheet
953
- raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)
954
-
955
- font = get_cell_font.dup
956
- font.set_size(font_size)
957
- update_font_references(font)
958
- end
959
-
960
- # Changes font color of cell
961
- def change_font_color(font_color = '000000')
962
- validate_worksheet
963
- Color.validate_color(font_color)
964
-
965
- font = get_cell_font.dup
966
- font.set_rgb_color(font_color)
967
- update_font_references(font)
968
- end
969
-
970
- # Changes font italics settings of cell
971
- def change_font_italics(italicized = false)
972
- validate_worksheet
973
-
974
- font = get_cell_font.dup
975
- font.set_italic(italicized)
976
- update_font_references(font)
977
- end
978
-
979
- # Changes font bold settings of cell
980
- def change_font_bold(bolded = false)
981
- validate_worksheet
982
-
983
- font = get_cell_font.dup
984
- font.set_bold(bolded)
985
- update_font_references(font)
986
- end
987
-
988
- # Changes font underline settings of cell
989
- def change_font_underline(underlined = false)
990
- validate_worksheet
991
-
992
- font = get_cell_font.dup
993
- font.set_underline(underlined)
994
- update_font_references(font)
995
- end
996
-
997
- def change_font_strikethrough(struckthrough = false)
998
- validate_worksheet
999
-
1000
- font = get_cell_font.dup
1001
- font.set_strikethrough(struckthrough)
1002
- update_font_references(font)
1003
- end
1004
-
1005
- # Helper method to update the font array and xf array
1006
- def update_font_references(modified_font)
1007
- xf = workbook.register_new_font(modified_font, get_cell_xf)
1008
- self.style_index = workbook.register_new_xf(xf)
1009
- end
1010
- private :update_font_references
1011
-
1012
- # Performs correct modification based on what type of change_type is specified
1013
- def font_switch(change_type, arg)
1014
- case change_type
1015
- when Worksheet::NAME then change_font_name(arg)
1016
- when Worksheet::SIZE then change_font_size(arg)
1017
- when Worksheet::COLOR then change_font_color(arg)
1018
- when Worksheet::ITALICS then change_font_italics(arg)
1019
- when Worksheet::BOLD then change_font_bold(arg)
1020
- when Worksheet::UNDERLINE then change_font_underline(arg)
1021
- when Worksheet::STRIKETHROUGH then change_font_strikethrough(arg)
1022
- else raise 'Invalid change_type'
1023
- end
1024
- end
1025
-
1026
- =begin
1027
- def add_hyperlink(l)
1028
- worksheet.hyperlinks ||= RubyXL::Hyperlinks.new
1029
- worksheet.hyperlinks << RubyXL::Hyperlink.new(:ref => self.r, :location => l)
1030
- # define_attribute(:'r:id', :string)
1031
- # define_attribute(:location, :string)
1032
- # define_attribute(:tooltip, :string)
1033
- # define_attribute(:display, :string)
1034
-
1035
- end
1036
-
1037
- def add_shared_string(str)
1038
- self.datatype = RubyXL::DataType::SHARED_STRING
1039
- self.raw_value = @workbook.shared_strings_container.add(str)
1040
- end
1041
- =end
1042
-
1043
- end
1044
-
1045
- end
1
+ require 'rubyXL/convenience_methods/workbook'
2
+ require 'rubyXL/convenience_methods/worksheet'
3
+ require 'rubyXL/convenience_methods/cell'
4
+ require 'rubyXL/convenience_methods/font'
5
+ require 'rubyXL/convenience_methods/color'