rubyXL 3.3.33 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +12 -0
  3. data/VERSION +1 -1
  4. data/lib/rubyXL/convenience_methods.rb +5 -1301
  5. data/lib/rubyXL/convenience_methods/cell.rb +262 -0
  6. data/lib/rubyXL/convenience_methods/color.rb +158 -0
  7. data/lib/rubyXL/convenience_methods/font.rb +63 -0
  8. data/lib/rubyXL/convenience_methods/workbook.rb +136 -0
  9. data/lib/rubyXL/convenience_methods/worksheet.rb +618 -0
  10. data/lib/rubyXL/objects/color.rb +0 -3
  11. data/lib/rubyXL/objects/external_links.rb +1 -1
  12. data/lib/rubyXL/objects/font.rb +0 -3
  13. data/lib/rubyXL/objects/sheet_data.rb +0 -2
  14. data/lib/rubyXL/objects/workbook.rb +95 -2
  15. data/lib/rubyXL/objects/worksheet.rb +0 -2
  16. data/rdoc/README_rdoc.html +24 -1
  17. data/rdoc/RubyXL.html +21 -1
  18. data/rdoc/RubyXL/AExtension.html +1 -1
  19. data/rdoc/RubyXL/AExtensionStorageArea.html +1 -1
  20. data/rdoc/RubyXL/ActiveX.html +1 -1
  21. data/rdoc/RubyXL/ActiveXBinary.html +1 -1
  22. data/rdoc/RubyXL/AdjustHandleList.html +1 -1
  23. data/rdoc/RubyXL/Alignment.html +1 -1
  24. data/rdoc/RubyXL/AlternateContent.html +1 -1
  25. data/rdoc/RubyXL/Authors.html +1 -1
  26. data/rdoc/RubyXL/AutoFilter.html +1 -1
  27. data/rdoc/RubyXL/AutoFilterColumn.html +1 -1
  28. data/rdoc/RubyXL/BinaryImageFile.html +1 -1
  29. data/rdoc/RubyXL/BodyProperties.html +1 -1
  30. data/rdoc/RubyXL/BooleanNode.html +1 -1
  31. data/rdoc/RubyXL/BooleanValue.html +1 -1
  32. data/rdoc/RubyXL/Border.html +1 -1
  33. data/rdoc/RubyXL/BorderEdge.html +1 -1
  34. data/rdoc/RubyXL/Borders.html +1 -1
  35. data/rdoc/RubyXL/Break.html +1 -1
  36. data/rdoc/RubyXL/BreakList.html +1 -1
  37. data/rdoc/RubyXL/CT_AdjPoint2D.html +1 -1
  38. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +1 -1
  39. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +1 -1
  40. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +1 -1
  41. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +1 -1
  42. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +1 -1
  43. data/rdoc/RubyXL/CT_Backdrop.html +1 -1
  44. data/rdoc/RubyXL/CT_Bevel.html +1 -1
  45. data/rdoc/RubyXL/CT_BiLevelEffect.html +1 -1
  46. data/rdoc/RubyXL/CT_BlendEffect.html +1 -1
  47. data/rdoc/RubyXL/CT_Blip.html +1 -1
  48. data/rdoc/RubyXL/CT_BlipFillProperties.html +1 -1
  49. data/rdoc/RubyXL/CT_BlurEffect.html +1 -1
  50. data/rdoc/RubyXL/CT_Camera.html +1 -1
  51. data/rdoc/RubyXL/CT_Color.html +1 -1
  52. data/rdoc/RubyXL/CT_ColorChangeEffect.html +1 -1
  53. data/rdoc/RubyXL/CT_ColorMapping.html +1 -1
  54. data/rdoc/RubyXL/CT_ColorScheme.html +1 -1
  55. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +1 -1
  56. data/rdoc/RubyXL/CT_ConnectionSite.html +1 -1
  57. data/rdoc/RubyXL/CT_ConnectionSiteList.html +1 -1
  58. data/rdoc/RubyXL/CT_DashStop.html +1 -1
  59. data/rdoc/RubyXL/CT_DashStopList.html +1 -1
  60. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +1 -1
  61. data/rdoc/RubyXL/CT_DuotoneEffect.html +1 -1
  62. data/rdoc/RubyXL/CT_EffectContainer.html +1 -1
  63. data/rdoc/RubyXL/CT_EffectList.html +1 -1
  64. data/rdoc/RubyXL/CT_EffectReference.html +1 -1
  65. data/rdoc/RubyXL/CT_EffectStyleItem.html +1 -1
  66. data/rdoc/RubyXL/CT_EffectStyleList.html +1 -1
  67. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +1 -1
  68. data/rdoc/RubyXL/CT_FillEffect.html +1 -1
  69. data/rdoc/RubyXL/CT_FillOverlayEffect.html +1 -1
  70. data/rdoc/RubyXL/CT_FillStyleList.html +1 -1
  71. data/rdoc/RubyXL/CT_FlatText.html +1 -1
  72. data/rdoc/RubyXL/CT_FontCollection.html +1 -1
  73. data/rdoc/RubyXL/CT_FontReference.html +1 -1
  74. data/rdoc/RubyXL/CT_GeomGuideList.html +1 -1
  75. data/rdoc/RubyXL/CT_GlowEffect.html +1 -1
  76. data/rdoc/RubyXL/CT_GradientFillProperties.html +1 -1
  77. data/rdoc/RubyXL/CT_GradientStop.html +1 -1
  78. data/rdoc/RubyXL/CT_GradientStopList.html +1 -1
  79. data/rdoc/RubyXL/CT_HSLEffect.html +1 -1
  80. data/rdoc/RubyXL/CT_HslColor.html +1 -1
  81. data/rdoc/RubyXL/CT_Hyperlink.html +1 -1
  82. data/rdoc/RubyXL/CT_InnerShadowEffect.html +1 -1
  83. data/rdoc/RubyXL/CT_LightRig.html +1 -1
  84. data/rdoc/RubyXL/CT_LineEndProperties.html +1 -1
  85. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +1 -1
  86. data/rdoc/RubyXL/CT_LineProperties.html +1 -1
  87. data/rdoc/RubyXL/CT_LineStyleList.html +1 -1
  88. data/rdoc/RubyXL/CT_LinearShadeProperties.html +1 -1
  89. data/rdoc/RubyXL/CT_LuminanceEffect.html +1 -1
  90. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +1 -1
  91. data/rdoc/RubyXL/CT_OuterShadowEffect.html +1 -1
  92. data/rdoc/RubyXL/CT_Path2D.html +1 -1
  93. data/rdoc/RubyXL/CT_Path2DArcTo.html +1 -1
  94. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +1 -1
  95. data/rdoc/RubyXL/CT_Path2DList.html +1 -1
  96. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +1 -1
  97. data/rdoc/RubyXL/CT_Path2DTo.html +1 -1
  98. data/rdoc/RubyXL/CT_PathShadeProperties.html +1 -1
  99. data/rdoc/RubyXL/CT_PatternFillProperties.html +1 -1
  100. data/rdoc/RubyXL/CT_Point3D.html +1 -1
  101. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +1 -1
  102. data/rdoc/RubyXL/CT_PresetColor.html +1 -1
  103. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +1 -1
  104. data/rdoc/RubyXL/CT_PresetShadowEffect.html +1 -1
  105. data/rdoc/RubyXL/CT_PresetTextShape.html +1 -1
  106. data/rdoc/RubyXL/CT_ReflectionEffect.html +1 -1
  107. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +1 -1
  108. data/rdoc/RubyXL/CT_RelativeRect.html +1 -1
  109. data/rdoc/RubyXL/CT_SRgbColor.html +1 -1
  110. data/rdoc/RubyXL/CT_ScRgbColor.html +1 -1
  111. data/rdoc/RubyXL/CT_Scene3D.html +1 -1
  112. data/rdoc/RubyXL/CT_SchemeColor.html +1 -1
  113. data/rdoc/RubyXL/CT_Shape3D.html +1 -1
  114. data/rdoc/RubyXL/CT_ShapeStyle.html +1 -1
  115. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +1 -1
  116. data/rdoc/RubyXL/CT_SphereCoords.html +1 -1
  117. data/rdoc/RubyXL/CT_StretchInfoProperties.html +1 -1
  118. data/rdoc/RubyXL/CT_StyleMatrix.html +1 -1
  119. data/rdoc/RubyXL/CT_StyleMatrixReference.html +1 -1
  120. data/rdoc/RubyXL/CT_SupplementalFont.html +1 -1
  121. data/rdoc/RubyXL/CT_SystemColor.html +1 -1
  122. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +1 -1
  123. data/rdoc/RubyXL/CT_TextBlipBullet.html +1 -1
  124. data/rdoc/RubyXL/CT_TextCharBullet.html +1 -1
  125. data/rdoc/RubyXL/CT_TextCharacterProperties.html +1 -1
  126. data/rdoc/RubyXL/CT_TextFont.html +1 -1
  127. data/rdoc/RubyXL/CT_TextListStyle.html +1 -1
  128. data/rdoc/RubyXL/CT_TextNormalAutofit.html +1 -1
  129. data/rdoc/RubyXL/CT_TextParagraphProperties.html +1 -1
  130. data/rdoc/RubyXL/CT_TextSpacing.html +1 -1
  131. data/rdoc/RubyXL/CT_TextTabStop.html +1 -1
  132. data/rdoc/RubyXL/CT_TextTabStopList.html +1 -1
  133. data/rdoc/RubyXL/CT_TileInfoProperties.html +1 -1
  134. data/rdoc/RubyXL/CT_TintEffect.html +1 -1
  135. data/rdoc/RubyXL/CT_Transform2D.html +1 -1
  136. data/rdoc/RubyXL/CT_TransformEffect.html +1 -1
  137. data/rdoc/RubyXL/CT_Vector3D.html +1 -1
  138. data/rdoc/RubyXL/CT_XYAdjustHandle.html +1 -1
  139. data/rdoc/RubyXL/CalculationChain.html +1 -1
  140. data/rdoc/RubyXL/CalculationChainCell.html +1 -1
  141. data/rdoc/RubyXL/CalculationProperties.html +1 -1
  142. data/rdoc/RubyXL/Cell.html +12 -16
  143. data/rdoc/RubyXL/CellConvenienceMethods.html +34 -34
  144. data/rdoc/RubyXL/CellExt.html +1 -1
  145. data/rdoc/RubyXL/CellSmartTag.html +1 -1
  146. data/rdoc/RubyXL/CellSmartTagProperty.html +1 -1
  147. data/rdoc/RubyXL/CellSmartTags.html +1 -1
  148. data/rdoc/RubyXL/CellStyle.html +1 -1
  149. data/rdoc/RubyXL/CellStyleXFs.html +1 -1
  150. data/rdoc/RubyXL/CellStyles.html +1 -1
  151. data/rdoc/RubyXL/CellValue.html +2 -2
  152. data/rdoc/RubyXL/CellWatch.html +1 -1
  153. data/rdoc/RubyXL/CellWatches.html +1 -1
  154. data/rdoc/RubyXL/CellXFs.html +1 -1
  155. data/rdoc/RubyXL/ChartColorsFile.html +1 -1
  156. data/rdoc/RubyXL/ChartFile.html +1 -1
  157. data/rdoc/RubyXL/ChartStyleFile.html +1 -1
  158. data/rdoc/RubyXL/ChartUserShapesFile.html +1 -1
  159. data/rdoc/RubyXL/Chartsheet.html +1 -1
  160. data/rdoc/RubyXL/ChartsheetPageSetup.html +1 -1
  161. data/rdoc/RubyXL/ChartsheetProperties.html +1 -1
  162. data/rdoc/RubyXL/ChartsheetProtection.html +1 -1
  163. data/rdoc/RubyXL/ChartsheetView.html +1 -1
  164. data/rdoc/RubyXL/ChartsheetViews.html +1 -1
  165. data/rdoc/RubyXL/Color.html +2 -13
  166. data/rdoc/RubyXL/ColorConvenienceClasses.html +1 -1
  167. data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +3 -3
  168. data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +4 -4
  169. data/rdoc/RubyXL/ColorConvenienceMethods.html +2 -2
  170. data/rdoc/RubyXL/ColorFilter.html +1 -1
  171. data/rdoc/RubyXL/ColorScale.html +1 -1
  172. data/rdoc/RubyXL/ColorSet.html +1 -1
  173. data/rdoc/RubyXL/Colors.html +1 -1
  174. data/rdoc/RubyXL/ColumnRange.html +1 -1
  175. data/rdoc/RubyXL/ColumnRanges.html +1 -1
  176. data/rdoc/RubyXL/Comment.html +1 -1
  177. data/rdoc/RubyXL/CommentList.html +1 -1
  178. data/rdoc/RubyXL/CommentsFile.html +1 -1
  179. data/rdoc/RubyXL/ConditionalFormatValue.html +1 -1
  180. data/rdoc/RubyXL/ConditionalFormatting.html +1 -1
  181. data/rdoc/RubyXL/ConditionalFormattingRule.html +1 -1
  182. data/rdoc/RubyXL/ContentTypeDefault.html +1 -1
  183. data/rdoc/RubyXL/ContentTypeOverride.html +1 -1
  184. data/rdoc/RubyXL/ContentTypes.html +1 -1
  185. data/rdoc/RubyXL/ControlPropertiesFile.html +1 -1
  186. data/rdoc/RubyXL/CorePropertiesFile.html +1 -1
  187. data/rdoc/RubyXL/CustomColor.html +1 -1
  188. data/rdoc/RubyXL/CustomColorList.html +1 -1
  189. data/rdoc/RubyXL/CustomFilter.html +1 -1
  190. data/rdoc/RubyXL/CustomFilters.html +1 -1
  191. data/rdoc/RubyXL/CustomGeometry.html +1 -1
  192. data/rdoc/RubyXL/CustomProperties.html +1 -1
  193. data/rdoc/RubyXL/CustomPropertiesFile.html +1 -1
  194. data/rdoc/RubyXL/CustomProperty.html +1 -1
  195. data/rdoc/RubyXL/CustomPropertyFile.html +1 -1
  196. data/rdoc/RubyXL/CustomSheetView.html +1 -1
  197. data/rdoc/RubyXL/CustomSheetViews.html +1 -1
  198. data/rdoc/RubyXL/CustomWorkbookView.html +1 -1
  199. data/rdoc/RubyXL/CustomWorkbookViews.html +1 -1
  200. data/rdoc/RubyXL/CustomXMLFile.html +1 -1
  201. data/rdoc/RubyXL/DXF.html +1 -1
  202. data/rdoc/RubyXL/DXFs.html +1 -1
  203. data/rdoc/RubyXL/DataBar.html +1 -1
  204. data/rdoc/RubyXL/DataConsolidate.html +1 -1
  205. data/rdoc/RubyXL/DataConsolidationReference.html +1 -1
  206. data/rdoc/RubyXL/DataConsolidationReferences.html +1 -1
  207. data/rdoc/RubyXL/DataType.html +1 -1
  208. data/rdoc/RubyXL/DataValidation.html +1 -1
  209. data/rdoc/RubyXL/DataValidations.html +1 -1
  210. data/rdoc/RubyXL/DateGroupItem.html +1 -1
  211. data/rdoc/RubyXL/DefinedName.html +1 -1
  212. data/rdoc/RubyXL/DefinedNameExt.html +1 -1
  213. data/rdoc/RubyXL/DefinedNames.html +1 -1
  214. data/rdoc/RubyXL/DefinedNamesExt.html +1 -1
  215. data/rdoc/RubyXL/DocumentPropertiesFile.html +1 -1
  216. data/rdoc/RubyXL/DrawingFile.html +1 -1
  217. data/rdoc/RubyXL/DynamicFilter.html +1 -1
  218. data/rdoc/RubyXL/EmbeddedControl.html +1 -1
  219. data/rdoc/RubyXL/EmbeddedControls.html +1 -1
  220. data/rdoc/RubyXL/Extension.html +1 -1
  221. data/rdoc/RubyXL/ExtensionStorageArea.html +1 -1
  222. data/rdoc/RubyXL/Extents.html +1 -1
  223. data/rdoc/RubyXL/ExternalBook.html +1 -1
  224. data/rdoc/RubyXL/ExternalLinksFile.html +1 -1
  225. data/rdoc/RubyXL/ExternalReference.html +1 -1
  226. data/rdoc/RubyXL/ExternalReferences.html +1 -1
  227. data/rdoc/RubyXL/ExtraColorSchemeList.html +1 -1
  228. data/rdoc/RubyXL/FieldItem.html +1 -1
  229. data/rdoc/RubyXL/FileRecoveryProperties.html +1 -1
  230. data/rdoc/RubyXL/FileSharing.html +1 -1
  231. data/rdoc/RubyXL/FileVersion.html +1 -1
  232. data/rdoc/RubyXL/Fill.html +1 -1
  233. data/rdoc/RubyXL/Fills.html +1 -1
  234. data/rdoc/RubyXL/FilterContainer.html +1 -1
  235. data/rdoc/RubyXL/FloatNode.html +1 -1
  236. data/rdoc/RubyXL/FloatValue.html +1 -1
  237. data/rdoc/RubyXL/Font.html +3 -14
  238. data/rdoc/RubyXL/FontConvenienceMethods.html +15 -15
  239. data/rdoc/RubyXL/FontScheme.html +1 -1
  240. data/rdoc/RubyXL/Fonts.html +2 -2
  241. data/rdoc/RubyXL/Formula.html +1 -1
  242. data/rdoc/RubyXL/FunctionGroup.html +1 -1
  243. data/rdoc/RubyXL/FunctionGroups.html +1 -1
  244. data/rdoc/RubyXL/GenericStorageObject.html +1 -1
  245. data/rdoc/RubyXL/GradientFill.html +1 -1
  246. data/rdoc/RubyXL/HeaderFooterSettings.html +1 -1
  247. data/rdoc/RubyXL/Hyperlink.html +1 -1
  248. data/rdoc/RubyXL/HyperlinkRelFile.html +1 -1
  249. data/rdoc/RubyXL/Hyperlinks.html +1 -1
  250. data/rdoc/RubyXL/IconFilter.html +1 -1
  251. data/rdoc/RubyXL/IconSet.html +1 -1
  252. data/rdoc/RubyXL/IgnoredError.html +1 -1
  253. data/rdoc/RubyXL/IgnoredErrors.html +1 -1
  254. data/rdoc/RubyXL/IndexedColors.html +1 -1
  255. data/rdoc/RubyXL/InputCells.html +1 -1
  256. data/rdoc/RubyXL/IntegerNode.html +1 -1
  257. data/rdoc/RubyXL/IntegerValue.html +1 -1
  258. data/rdoc/RubyXL/LegacyCell.html +1 -1
  259. data/rdoc/RubyXL/LegacyWorksheet.html +1 -1
  260. data/rdoc/RubyXL/MRUColors.html +1 -1
  261. data/rdoc/RubyXL/MacrosFile.html +1 -1
  262. data/rdoc/RubyXL/MergedCell.html +1 -1
  263. data/rdoc/RubyXL/MergedCells.html +1 -1
  264. data/rdoc/RubyXL/NumFmt.html +1 -1
  265. data/rdoc/RubyXL/NumberFormat.html +1 -1
  266. data/rdoc/RubyXL/NumberFormats.html +1 -1
  267. data/rdoc/RubyXL/OLEObject.html +1 -1
  268. data/rdoc/RubyXL/OLEObjectFile.html +1 -1
  269. data/rdoc/RubyXL/OLEObjects.html +1 -1
  270. data/rdoc/RubyXL/OLESize.html +1 -1
  271. data/rdoc/RubyXL/OOXMLContainerObject.html +1 -1
  272. data/rdoc/RubyXL/OOXMLIgnored.html +1 -1
  273. data/rdoc/RubyXL/OOXMLObject.html +1 -1
  274. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +1 -1
  275. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +1 -1
  276. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +1 -1
  277. data/rdoc/RubyXL/OOXMLTopLevelObject.html +1 -1
  278. data/rdoc/RubyXL/Offset.html +1 -1
  279. data/rdoc/RubyXL/OutlineProperties.html +1 -1
  280. data/rdoc/RubyXL/PageMargins.html +1 -1
  281. data/rdoc/RubyXL/PageSetup.html +1 -1
  282. data/rdoc/RubyXL/PageSetupProperties.html +1 -1
  283. data/rdoc/RubyXL/Pane.html +1 -1
  284. data/rdoc/RubyXL/Parser.html +1 -1
  285. data/rdoc/RubyXL/PatternFill.html +1 -1
  286. data/rdoc/RubyXL/PhoneticProperties.html +1 -1
  287. data/rdoc/RubyXL/PhoneticRun.html +1 -1
  288. data/rdoc/RubyXL/PivotArea.html +1 -1
  289. data/rdoc/RubyXL/PivotCache.html +1 -1
  290. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +1 -1
  291. data/rdoc/RubyXL/PivotCacheRecordsFile.html +1 -1
  292. data/rdoc/RubyXL/PivotCaches.html +1 -1
  293. data/rdoc/RubyXL/PivotReference.html +1 -1
  294. data/rdoc/RubyXL/PivotReferences.html +1 -1
  295. data/rdoc/RubyXL/PivotTableFile.html +1 -1
  296. data/rdoc/RubyXL/PivotTableSelection.html +1 -1
  297. data/rdoc/RubyXL/PresetGeometry.html +1 -1
  298. data/rdoc/RubyXL/PrintOptions.html +1 -1
  299. data/rdoc/RubyXL/PrinterSettingsFile.html +1 -1
  300. data/rdoc/RubyXL/ProtectedRange.html +1 -1
  301. data/rdoc/RubyXL/ProtectedRanges.html +1 -1
  302. data/rdoc/RubyXL/Protection.html +1 -1
  303. data/rdoc/RubyXL/RID.html +1 -1
  304. data/rdoc/RubyXL/RawOOXML.html +1 -1
  305. data/rdoc/RubyXL/Reference.html +1 -1
  306. data/rdoc/RubyXL/Relationship.html +1 -1
  307. data/rdoc/RubyXL/RelationshipSupport.html +1 -1
  308. data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +1 -1
  309. data/rdoc/RubyXL/RevisionPointer.html +1 -1
  310. data/rdoc/RubyXL/RichText.html +1 -1
  311. data/rdoc/RubyXL/RichTextRun.html +1 -1
  312. data/rdoc/RubyXL/Row.html +10 -10
  313. data/rdoc/RubyXL/RowExt.html +1 -1
  314. data/rdoc/RubyXL/RunProperties.html +1 -1
  315. data/rdoc/RubyXL/Scenario.html +1 -1
  316. data/rdoc/RubyXL/Scenarios.html +1 -1
  317. data/rdoc/RubyXL/Selection.html +2 -2
  318. data/rdoc/RubyXL/ShapeGuide.html +1 -1
  319. data/rdoc/RubyXL/ShapeTextRectangle.html +1 -1
  320. data/rdoc/RubyXL/SharedStringsTable.html +1 -1
  321. data/rdoc/RubyXL/Sheet.html +1 -1
  322. data/rdoc/RubyXL/SheetCalculationProperties.html +1 -1
  323. data/rdoc/RubyXL/SheetData.html +3 -3
  324. data/rdoc/RubyXL/SheetDataExt.html +1 -1
  325. data/rdoc/RubyXL/SheetDataSet.html +1 -1
  326. data/rdoc/RubyXL/SheetName.html +1 -1
  327. data/rdoc/RubyXL/SheetNames.html +1 -1
  328. data/rdoc/RubyXL/Sheets.html +1 -1
  329. data/rdoc/RubyXL/SlicerCacheFile.html +1 -1
  330. data/rdoc/RubyXL/SlicerFile.html +1 -1
  331. data/rdoc/RubyXL/SmartTagProperties.html +1 -1
  332. data/rdoc/RubyXL/SmartTagType.html +1 -1
  333. data/rdoc/RubyXL/SmartTagTypes.html +1 -1
  334. data/rdoc/RubyXL/SmartTags.html +1 -1
  335. data/rdoc/RubyXL/SortCondition.html +1 -1
  336. data/rdoc/RubyXL/SortState.html +1 -1
  337. data/rdoc/RubyXL/Sqref.html +1 -1
  338. data/rdoc/RubyXL/Stop.html +1 -1
  339. data/rdoc/RubyXL/StringNode.html +1 -1
  340. data/rdoc/RubyXL/StringNodeW3C.html +1 -1
  341. data/rdoc/RubyXL/StringValue.html +1 -1
  342. data/rdoc/RubyXL/Stylesheet.html +1 -1
  343. data/rdoc/RubyXL/TableFile.html +1 -1
  344. data/rdoc/RubyXL/TableParts.html +1 -1
  345. data/rdoc/RubyXL/TableStyle.html +1 -1
  346. data/rdoc/RubyXL/TableStyles.html +1 -1
  347. data/rdoc/RubyXL/Text.html +1 -1
  348. data/rdoc/RubyXL/Theme.html +1 -1
  349. data/rdoc/RubyXL/ThemeElements.html +1 -1
  350. data/rdoc/RubyXL/ThumbnailFile.html +1 -1
  351. data/rdoc/RubyXL/Top10.html +1 -1
  352. data/rdoc/RubyXL/VMLDrawingFile.html +1 -1
  353. data/rdoc/RubyXL/Variant.html +1 -1
  354. data/rdoc/RubyXL/Vector.html +1 -1
  355. data/rdoc/RubyXL/VectorValue.html +1 -1
  356. data/rdoc/RubyXL/VisualProperties.html +1 -1
  357. data/rdoc/RubyXL/WebPublishObject.html +1 -1
  358. data/rdoc/RubyXL/WebPublishObjects.html +1 -1
  359. data/rdoc/RubyXL/WebPublishingItem.html +1 -1
  360. data/rdoc/RubyXL/WebPublishingItems.html +1 -1
  361. data/rdoc/RubyXL/WebPublishingProperties.html +1 -1
  362. data/rdoc/RubyXL/Workbook.html +664 -14
  363. data/rdoc/RubyXL/WorkbookConvenienceMethods.html +54 -640
  364. data/rdoc/RubyXL/WorkbookProperties.html +1 -1
  365. data/rdoc/RubyXL/WorkbookProtection.html +1 -1
  366. data/rdoc/RubyXL/WorkbookRoot.html +1 -1
  367. data/rdoc/RubyXL/WorkbookView.html +1 -1
  368. data/rdoc/RubyXL/WorkbookViews.html +1 -1
  369. data/rdoc/RubyXL/Worksheet.html +5 -9
  370. data/rdoc/RubyXL/WorksheetConvenienceMethods.html +69 -69
  371. data/rdoc/RubyXL/WorksheetDimensions.html +1 -1
  372. data/rdoc/RubyXL/WorksheetFormatProperties.html +1 -1
  373. data/rdoc/RubyXL/WorksheetProperties.html +1 -1
  374. data/rdoc/RubyXL/WorksheetProtection.html +1 -1
  375. data/rdoc/RubyXL/WorksheetView.html +1 -1
  376. data/rdoc/RubyXL/WorksheetViews.html +1 -1
  377. data/rdoc/RubyXL/XF.html +1 -1
  378. data/rdoc/created.rid +14 -9
  379. data/rdoc/index.html +2 -2
  380. data/rdoc/js/navigation.js.gz +0 -0
  381. data/rdoc/js/search_index.js +1 -1
  382. data/rdoc/js/search_index.js.gz +0 -0
  383. data/rdoc/js/searcher.js.gz +0 -0
  384. data/rdoc/table_of_contents.html +49 -38
  385. data/rubyXL.gemspec +8 -3
  386. data/spec/lib/cell_spec.rb +2 -0
  387. data/spec/lib/color_spec.rb +1 -0
  388. data/spec/lib/workbook_spec.rb +11 -0
  389. data/spec/lib/worksheet_spec.rb +1 -0
  390. metadata +7 -2
@@ -0,0 +1,136 @@
1
+ module RubyXL
2
+
3
+ module WorkbookConvenienceMethods
4
+
5
+ def each
6
+ worksheets.each{ |i| yield i }
7
+ end
8
+
9
+ def cell_xfs # Stylesheet should be pre-filled with defaults on initialize()
10
+ stylesheet.cell_xfs
11
+ end
12
+
13
+ def fonts # Stylesheet should be pre-filled with defaults on initialize()
14
+ stylesheet.fonts
15
+ end
16
+
17
+ def fills # Stylesheet should be pre-filled with defaults on initialize()
18
+ stylesheet.fills
19
+ end
20
+
21
+ def borders # Stylesheet should be pre-filled with defaults on initialize()
22
+ stylesheet.borders
23
+ end
24
+
25
+ def get_fill_color(xf)
26
+ fill = fills[xf.fill_id]
27
+ pattern = fill && fill.pattern_fill
28
+ color = pattern && pattern.fg_color
29
+ color = color && color.get_rgb(self)
30
+ color && color.to_s || 'ffffff'
31
+ end
32
+
33
+ def register_new_fill(new_fill, old_xf)
34
+ new_xf = old_xf.dup
35
+ new_xf.apply_fill = true
36
+ new_xf.fill_id = fills.find_index { |x| x == new_fill } # Reuse existing fill, if it exists
37
+ new_xf.fill_id ||= fills.size # If this fill has never existed before, add it to collection.
38
+ fills[new_xf.fill_id] = new_fill
39
+ new_xf
40
+ end
41
+
42
+ def register_new_font(new_font, old_xf)
43
+ new_xf = old_xf.dup
44
+ new_xf.font_id = fonts.find_index { |x| x == new_font } # Reuse existing font, if it exists
45
+ new_xf.font_id ||= fonts.size # If this font has never existed before, add it to collection.
46
+ fonts[new_xf.font_id] = new_font
47
+ new_xf.apply_font = true
48
+ new_xf
49
+ end
50
+
51
+ def register_new_xf(new_xf)
52
+ new_xf_id = cell_xfs.find_index { |xf| xf == new_xf } # Reuse existing XF, if it exists
53
+ new_xf_id ||= cell_xfs.size # If this XF has never existed before, add it to collection.
54
+ cell_xfs[new_xf_id] = new_xf
55
+ new_xf_id
56
+ end
57
+
58
+ def modify_alignment(style_index, &block)
59
+ old_xf = cell_xfs[style_index || 0]
60
+ new_xf = old_xf.dup
61
+ if old_xf.alignment then
62
+ new_xf.alignment = old_xf.alignment.dup
63
+ else
64
+ new_xf.alignment = RubyXL::Alignment.new
65
+ end
66
+
67
+ yield(new_xf.alignment)
68
+ new_xf.apply_alignment = true
69
+
70
+ register_new_xf(new_xf)
71
+ end
72
+
73
+ def modify_fill(style_index, rgb)
74
+ xf = cell_xfs[style_index || 0].dup
75
+ new_fill = RubyXL::Fill.new(:pattern_fill =>
76
+ RubyXL::PatternFill.new(:pattern_type => 'solid',
77
+ :fg_color => RubyXL::Color.new(:rgb => rgb)))
78
+ register_new_xf(register_new_fill(new_fill, xf))
79
+ end
80
+
81
+ def modify_border(style_index, direction, weight)
82
+ xf = cell_xfs[style_index || 0].dup
83
+ new_border = borders[xf.border_id || 0].dup
84
+
85
+ edge = new_border.send(direction)
86
+ new_border.send("#{direction}=", edge.dup) if edge
87
+
88
+ new_border.set_edge_style(direction, weight)
89
+
90
+ xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
91
+ xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
92
+ borders[xf.border_id] = new_border
93
+ xf.apply_border = true
94
+
95
+ register_new_xf(xf)
96
+ end
97
+
98
+ def modify_border_color(style_index, direction, color)
99
+ xf = cell_xfs[style_index || 0].dup
100
+ new_border = borders[xf.border_id || 0].dup
101
+ new_border.set_edge_color(direction, color)
102
+
103
+ xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
104
+ xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
105
+ borders[xf.border_id] = new_border
106
+ xf.apply_border = true
107
+
108
+ register_new_xf(xf)
109
+ end
110
+
111
+ # Calculate password hash from string for use in 'password' fields.
112
+ # https://www.openoffice.org/sc/excelfileformat.pdf
113
+ def password_hash(pwd)
114
+ hsh = 0
115
+ pwd.reverse.each_char { |c|
116
+ hsh = hsh ^ c.ord
117
+ hsh = hsh << 1
118
+ hsh -= 0x7fff if hsh > 0x7fff
119
+ }
120
+
121
+ (hsh ^ pwd.length ^ 0xCE4B).to_s(16)
122
+ end
123
+
124
+ def define_new_name(name, reference)
125
+ self.defined_names ||= RubyXL::DefinedNames.new
126
+ self.defined_names << RubyXL::DefinedName.new({:name => name, :reference => reference})
127
+ end
128
+
129
+ def get_defined_name(name)
130
+ self.defined_names && self.defined_names.find { |n| n.name == name }
131
+ end
132
+
133
+ end
134
+
135
+ RubyXL::Workbook.include(RubyXL::WorkbookConvenienceMethods)
136
+ end
@@ -0,0 +1,618 @@
1
+ module RubyXL
2
+
3
+ module WorksheetConvenienceMethods
4
+ NAME = 0
5
+ SIZE = 1
6
+ COLOR = 2
7
+ ITALICS = 3
8
+ BOLD = 4
9
+ UNDERLINE = 5
10
+ STRIKETHROUGH = 6
11
+
12
+ def insert_cell(row = 0, col = 0, data = nil, formula = nil, shift = nil)
13
+ validate_workbook
14
+ ensure_cell_exists(row, col)
15
+
16
+ case shift
17
+ when nil then # No shifting at all
18
+ when :right then
19
+ sheet_data.rows[row].insert_cell_shift_right(nil, col)
20
+ when :down then
21
+ add_row(sheet_data.size, :cells => Array.new(sheet_data.rows[row].size))
22
+ (sheet_data.size - 1).downto(row+1) { |index|
23
+ sheet_data.rows[index].cells[col] = sheet_data.rows[index-1].cells[col]
24
+ }
25
+ else
26
+ raise 'invalid shift option'
27
+ end
28
+
29
+ return add_cell(row, col, data, formula)
30
+ end
31
+
32
+ # by default, only sets cell to nil
33
+ # if :left is specified, method will shift row contents to the right of the deleted cell to the left
34
+ # if :up is specified, method will shift column contents below the deleted cell upward
35
+ def delete_cell(row_index = 0, column_index=0, shift=nil)
36
+ validate_workbook
37
+ validate_nonnegative(row_index)
38
+ validate_nonnegative(column_index)
39
+
40
+ row = sheet_data[row_index]
41
+ old_cell = row && row[column_index]
42
+
43
+ case shift
44
+ when nil then
45
+ row.cells[column_index] = nil if row
46
+ when :left then
47
+ row.delete_cell_shift_left(column_index) if row
48
+ when :up then
49
+ (row_index...(sheet_data.size - 1)).each { |index|
50
+ c = sheet_data.rows[index].cells[column_index] = sheet_data.rows[index + 1].cells[column_index]
51
+ c.row -= 1 if c.is_a?(Cell)
52
+ }
53
+ else
54
+ raise 'invalid shift option'
55
+ end
56
+
57
+ return old_cell
58
+ end
59
+
60
+ # Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!)
61
+ # NOTE: use of this method will break formulas which reference cells which are being "pushed down"
62
+ def insert_row(row_index = 0)
63
+ validate_workbook
64
+ ensure_cell_exists(row_index)
65
+
66
+ old_row = new_cells = nil
67
+
68
+ if row_index > 0 then
69
+ old_row = sheet_data.rows[row_index - 1]
70
+ if old_row then
71
+ new_cells = old_row.cells.collect { |c|
72
+ if c.nil? then nil
73
+ else nc = RubyXL::Cell.new(:style_index => c.style_index)
74
+ nc.worksheet = self
75
+ nc
76
+ end
77
+ }
78
+ end
79
+ end
80
+
81
+ row0 = sheet_data.rows[0]
82
+ new_cells ||= Array.new((row0 && row0.cells.size) || 0)
83
+
84
+ sheet_data.rows.insert(row_index, nil)
85
+ new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
86
+
87
+ # Update row values for all rows below
88
+ row_index.upto(sheet_data.rows.size - 1) { |r|
89
+ row = sheet_data.rows[r]
90
+ next if row.nil?
91
+ row.cells.each_with_index { |cell, c|
92
+ next if cell.nil?
93
+ cell.r = RubyXL::Reference.new(r, c)
94
+ }
95
+ }
96
+
97
+ return new_row
98
+ end
99
+
100
+ def delete_row(row_index=0)
101
+ validate_workbook
102
+ validate_nonnegative(row_index)
103
+
104
+ deleted = sheet_data.rows.delete_at(row_index)
105
+
106
+ # Update row number of each cell
107
+ row_index.upto(sheet_data.size - 1) { |index|
108
+ row = sheet_data[index]
109
+ row && row.cells.each{ |c| c.row -= 1 unless c.nil? }
110
+ }
111
+
112
+ return deleted
113
+ end
114
+
115
+ # Inserts column at +column_index+, pushes everything right, takes styles from column to left
116
+ # NOTE: use of this method will break formulas which reference cells which are being "pushed right"
117
+ def insert_column(column_index = 0)
118
+ validate_workbook
119
+ ensure_cell_exists(0, column_index)
120
+
121
+ old_range = cols.get_range(column_index)
122
+
123
+ #go through each cell in column
124
+ sheet_data.rows.each_with_index { |row, row_index|
125
+ old_cell = row[column_index]
126
+ c = nil
127
+
128
+ if old_cell && old_cell.style_index != 0 &&
129
+ old_range && old_range.style_index != old_cell.style_index then
130
+
131
+ c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
132
+ :row => row_index, :column => column_index,
133
+ :datatype => RubyXL::DataType::SHARED_STRING)
134
+ end
135
+
136
+ row.insert_cell_shift_right(c, column_index)
137
+ }
138
+
139
+ cols.insert_column(column_index)
140
+
141
+ # TODO: update column numbers
142
+ end
143
+
144
+ def delete_column(column_index = 0)
145
+ validate_workbook
146
+ validate_nonnegative(column_index)
147
+
148
+ # Delete column
149
+ sheet_data.rows.each { |row| row.cells.delete_at(column_index) }
150
+
151
+ # Update column numbers for cells to the right of the deleted column
152
+ sheet_data.rows.each_with_index { |row, row_index|
153
+ row.cells.each_with_index { |c, ci|
154
+ c.column = ci if c.is_a?(Cell)
155
+ }
156
+ }
157
+
158
+ cols.each { |range| range.delete_column(column_index) }
159
+ end
160
+
161
+ def get_row_style(row_index)
162
+ row = sheet_data.rows[row_index]
163
+ (row && row.style_index) || 0
164
+ end
165
+
166
+ def get_row_fill(row = 0)
167
+ (row = sheet_data.rows[row]) && row.get_fill_color
168
+ end
169
+
170
+ def get_row_font_name(row = 0)
171
+ (font = row_font(row)) && font.get_name
172
+ end
173
+
174
+ def get_row_font_size(row = 0)
175
+ (font = row_font(row)) && font.get_size
176
+ end
177
+
178
+ def get_row_font_color(row = 0)
179
+ font = row_font(row)
180
+ color = font && font.color
181
+ color && (color.rgb || '000000')
182
+ end
183
+
184
+ def is_row_italicized(row = 0)
185
+ (font = row_font(row)) && font.is_italic
186
+ end
187
+
188
+ def is_row_bolded(row = 0)
189
+ (font = row_font(row)) && font.is_bold
190
+ end
191
+
192
+ def is_row_underlined(row = 0)
193
+ (font = row_font(row)) && font.is_underlined
194
+ end
195
+
196
+ def is_row_struckthrough(row = 0)
197
+ (font = row_font(row)) && font.is_strikethrough
198
+ end
199
+
200
+ def get_row_height(row = 0)
201
+ validate_workbook
202
+ validate_nonnegative(row)
203
+ row = sheet_data.rows[row]
204
+ row && row.ht || RubyXL::Row::DEFAULT_HEIGHT
205
+ end
206
+
207
+ def get_row_border(row, border_direction)
208
+ validate_workbook
209
+
210
+ border = @workbook.borders[get_row_xf(row).border_id]
211
+ border && border.get_edge_style(border_direction)
212
+ end
213
+
214
+ def get_row_border_color(row, border_direction)
215
+ validate_workbook
216
+
217
+ border = @workbook.borders[get_row_xf(row).border_id]
218
+ border && border.get_edge_color(border_direction)
219
+ end
220
+
221
+ def row_font(row)
222
+ (row = sheet_data.rows[row]) && row.get_font
223
+ end
224
+
225
+ def get_row_alignment(row, is_horizontal)
226
+ validate_workbook
227
+
228
+ xf_obj = get_row_xf(row)
229
+ return nil if xf_obj.alignment.nil?
230
+
231
+ if is_horizontal then return xf_obj.alignment.horizontal
232
+ else return xf_obj.alignment.vertical
233
+ end
234
+ end
235
+
236
+ def get_cols_style_index(column_index)
237
+ validate_nonnegative(column_index)
238
+ range = cols.locate_range(column_index)
239
+ (range && range.style_index) || 0
240
+ end
241
+
242
+ def get_column_font_name(col = 0)
243
+ font = column_font(col)
244
+ font && font.get_name
245
+ end
246
+
247
+ def get_column_font_size(col = 0)
248
+ font = column_font(col)
249
+ font && font.get_size
250
+ end
251
+
252
+ def get_column_font_color(col = 0)
253
+ font = column_font(col)
254
+ font && (font.get_rgb_color || '000000')
255
+ end
256
+
257
+ def is_column_italicized(col = 0)
258
+ font = column_font(col)
259
+ font && font.is_italic
260
+ end
261
+
262
+ def is_column_bolded(col = 0)
263
+ font = column_font(col)
264
+ font && font.is_bold
265
+ end
266
+
267
+ def is_column_underlined(col = 0)
268
+ font = column_font(col)
269
+ font && font.is_underlined
270
+ end
271
+
272
+ def is_column_struckthrough(col = 0)
273
+ font = column_font(col)
274
+ font && font.is_strikethrough
275
+ end
276
+
277
+ # Get raw column width value as stored in the file
278
+ def get_column_width_raw(column_index = 0)
279
+ validate_workbook
280
+ validate_nonnegative(column_index)
281
+
282
+ range = cols.locate_range(column_index)
283
+ range && range.width
284
+ end
285
+
286
+ # Get column width measured in number of digits, as per
287
+ # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
288
+ def get_column_width(column_index = 0)
289
+ width = get_column_width_raw(column_index)
290
+ return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
291
+ (width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
292
+ end
293
+
294
+ # Set raw column width value
295
+ def change_column_width_raw(column_index, width)
296
+ validate_workbook
297
+ ensure_cell_exists(0, column_index)
298
+ range = cols.get_range(column_index)
299
+ range.width = width
300
+ range.custom_width = true
301
+ end
302
+
303
+ # Get column width measured in number of digits, as per
304
+ # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
305
+ def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
306
+ change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
307
+ end
308
+
309
+ # Helper method to get the style index for a column
310
+ def get_col_style(column_index)
311
+ range = cols.locate_range(column_index)
312
+ (range && range.style_index) || 0
313
+ end
314
+
315
+ def get_column_fill(col=0)
316
+ validate_workbook
317
+ validate_nonnegative(col)
318
+
319
+ @workbook.get_fill_color(get_col_xf(col))
320
+ end
321
+
322
+ def change_column_fill(column_index, color_code = 'ffffff')
323
+ validate_workbook
324
+ RubyXL::Color.validate_color(color_code)
325
+ ensure_cell_exists(0, column_index)
326
+
327
+ cols.get_range(column_index).style_index = @workbook.modify_fill(get_col_style(column_index), color_code)
328
+
329
+ sheet_data.rows.each { |row|
330
+ c = row[column_index]
331
+ c.change_fill(color_code) if c
332
+ }
333
+ end
334
+
335
+ def get_column_border(col, border_direction)
336
+ validate_workbook
337
+
338
+ xf = @workbook.cell_xfs[get_cols_style_index(col)]
339
+ border = @workbook.borders[xf.border_id]
340
+ border && border.get_edge_style(border_direction)
341
+ end
342
+
343
+ def get_column_border_color(col, border_direction)
344
+ validate_workbook
345
+
346
+ xf = @workbook.cell_xfs[get_cols_style_index(col)]
347
+ border = @workbook.borders[xf.border_id]
348
+ border && border.get_edge_color(border_direction)
349
+ end
350
+
351
+ def column_font(col)
352
+ validate_workbook
353
+
354
+ @workbook.fonts[@workbook.cell_xfs[get_cols_style_index(col)].font_id]
355
+ end
356
+
357
+ def get_column_alignment(col, type)
358
+ validate_workbook
359
+
360
+ xf = @workbook.cell_xfs[get_cols_style_index(col)]
361
+ xf.alignment && xf.alignment.send(type)
362
+ end
363
+
364
+ def change_row_horizontal_alignment(row = 0, alignment = 'center')
365
+ validate_workbook
366
+ validate_nonnegative(row)
367
+ change_row_alignment(row) { |a| a.horizontal = alignment }
368
+ end
369
+
370
+ def change_row_vertical_alignment(row = 0, alignment = 'center')
371
+ validate_workbook
372
+ validate_nonnegative(row)
373
+ change_row_alignment(row) { |a| a.vertical = alignment }
374
+ end
375
+
376
+ def change_row_border(row, direction, weight)
377
+ validate_workbook
378
+ ensure_cell_exists(row)
379
+
380
+ sheet_data.rows[row].style_index = @workbook.modify_border(get_row_style(row), direction, weight)
381
+
382
+ sheet_data[row].cells.each { |c|
383
+ c.change_border(direction, weight) unless c.nil?
384
+ }
385
+ end
386
+
387
+ def change_row_border_color(row, direction, color = '000000')
388
+ validate_workbook
389
+ ensure_cell_exists(row)
390
+ Color.validate_color(color)
391
+
392
+ sheet_data.rows[row].style_index = @workbook.modify_border_color(get_row_style(row), direction, color)
393
+
394
+ sheet_data[row].cells.each { |c|
395
+ c.change_border_color(direction, color) unless c.nil?
396
+ }
397
+ end
398
+
399
+ def change_row_fill(row_index = 0, rgb = 'ffffff')
400
+ validate_workbook
401
+ ensure_cell_exists(row_index)
402
+ Color.validate_color(rgb)
403
+
404
+ sheet_data.rows[row_index].style_index = @workbook.modify_fill(get_row_style(row_index), rgb)
405
+ sheet_data[row_index].cells.each { |c| c.change_fill(rgb) unless c.nil? }
406
+ end
407
+
408
+ # Helper method to update the row styles array
409
+ # change_type - NAME or SIZE or COLOR etc
410
+ # main method to change font, called from each separate font mutator method
411
+ def change_row_font(row_index, change_type, arg, font)
412
+ validate_workbook
413
+ ensure_cell_exists(row_index)
414
+
415
+ xf = workbook.register_new_font(font, get_row_xf(row_index))
416
+ row = sheet_data[row_index]
417
+ row.style_index = workbook.register_new_xf(xf)
418
+ row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
419
+ end
420
+
421
+ def change_row_font_name(row = 0, font_name = 'Verdana')
422
+ ensure_cell_exists(row)
423
+ font = row_font(row).dup
424
+ font.set_name(font_name)
425
+ change_row_font(row, Worksheet::NAME, font_name, font)
426
+ end
427
+
428
+ def change_row_font_size(row = 0, font_size=10)
429
+ ensure_cell_exists(row)
430
+ font = row_font(row).dup
431
+ font.set_size(font_size)
432
+ change_row_font(row, Worksheet::SIZE, font_size, font)
433
+ end
434
+
435
+ def change_row_font_color(row = 0, font_color = '000000')
436
+ ensure_cell_exists(row)
437
+ Color.validate_color(font_color)
438
+ font = row_font(row).dup
439
+ font.set_rgb_color(font_color)
440
+ change_row_font(row, Worksheet::COLOR, font_color, font)
441
+ end
442
+
443
+ def change_row_italics(row = 0, italicized = false)
444
+ ensure_cell_exists(row)
445
+ font = row_font(row).dup
446
+ font.set_italic(italicized)
447
+ change_row_font(row, Worksheet::ITALICS, italicized, font)
448
+ end
449
+
450
+ def change_row_bold(row = 0, bolded = false)
451
+ ensure_cell_exists(row)
452
+ font = row_font(row).dup
453
+ font.set_bold(bolded)
454
+ change_row_font(row, Worksheet::BOLD, bolded, font)
455
+ end
456
+
457
+ def change_row_underline(row = 0, underlined=false)
458
+ ensure_cell_exists(row)
459
+ font = row_font(row).dup
460
+ font.set_underline(underlined)
461
+ change_row_font(row, Worksheet::UNDERLINE, underlined, font)
462
+ end
463
+
464
+ def change_row_strikethrough(row = 0, struckthrough=false)
465
+ ensure_cell_exists(row)
466
+ font = row_font(row).dup
467
+ font.set_strikethrough(struckthrough)
468
+ change_row_font(row, Worksheet::STRIKETHROUGH, struckthrough, font)
469
+ end
470
+
471
+ def change_row_height(row = 0, height = 10)
472
+ validate_workbook
473
+ ensure_cell_exists(row)
474
+
475
+ c = sheet_data.rows[row]
476
+ c.ht = height
477
+ c.custom_height = true
478
+ end
479
+
480
+ # Helper method to update the fonts and cell styles array
481
+ # main method to change font, called from each separate font mutator method
482
+ def change_column_font(column_index, change_type, arg, font, xf)
483
+ validate_workbook
484
+ ensure_cell_exists(0, column_index)
485
+
486
+ xf = workbook.register_new_font(font, xf)
487
+ cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
488
+
489
+ sheet_data.rows.each { |row|
490
+ c = row && row[column_index]
491
+ c.font_switch(change_type, arg) unless c.nil?
492
+ }
493
+ end
494
+
495
+ def change_column_font_name(column_index = 0, font_name = 'Verdana')
496
+ xf = get_col_xf(column_index)
497
+ font = @workbook.fonts[xf.font_id].dup
498
+ font.set_name(font_name)
499
+ change_column_font(column_index, Worksheet::NAME, font_name, font, xf)
500
+ end
501
+
502
+ def change_column_font_size(column_index, font_size=10)
503
+ xf = get_col_xf(column_index)
504
+ font = @workbook.fonts[xf.font_id].dup
505
+ font.set_size(font_size)
506
+ change_column_font(column_index, Worksheet::SIZE, font_size, font, xf)
507
+ end
508
+
509
+ def change_column_font_color(column_index, font_color='000000')
510
+ Color.validate_color(font_color)
511
+
512
+ xf = get_col_xf(column_index)
513
+ font = @workbook.fonts[xf.font_id].dup
514
+ font.set_rgb_color(font_color)
515
+ change_column_font(column_index, Worksheet::COLOR, font_color, font, xf)
516
+ end
517
+
518
+ def change_column_italics(column_index, italicized = false)
519
+ xf = get_col_xf(column_index)
520
+ font = @workbook.fonts[xf.font_id].dup
521
+ font.set_italic(italicized)
522
+ change_column_font(column_index, Worksheet::ITALICS, italicized, font, xf)
523
+ end
524
+
525
+ def change_column_bold(column_index, bolded = false)
526
+ xf = get_col_xf(column_index)
527
+ font = @workbook.fonts[xf.font_id].dup
528
+ font.set_bold(bolded)
529
+ change_column_font(column_index, Worksheet::BOLD, bolded, font, xf)
530
+ end
531
+
532
+ def change_column_underline(column_index, underlined = false)
533
+ xf = get_col_xf(column_index)
534
+ font = @workbook.fonts[xf.font_id].dup
535
+ font.set_underline(underlined)
536
+ change_column_font(column_index, Worksheet::UNDERLINE, underlined, font, xf)
537
+ end
538
+
539
+ def change_column_strikethrough(column_index, struckthrough=false)
540
+ xf = get_col_xf(column_index)
541
+ font = @workbook.fonts[xf.font_id].dup
542
+ font.set_strikethrough(struckthrough)
543
+ change_column_font(column_index, Worksheet::STRIKETHROUGH, struckthrough, font, xf)
544
+ end
545
+
546
+ def change_column_horizontal_alignment(column_index, alignment = 'center')
547
+ change_column_alignment(column_index) { |a| a.horizontal = alignment }
548
+ end
549
+
550
+ def change_column_vertical_alignment(column_index, alignment = 'center')
551
+ change_column_alignment(column_index) { |a| a.vertical = alignment }
552
+ end
553
+
554
+ def change_column_border(column_index, direction, weight)
555
+ validate_workbook
556
+ ensure_cell_exists(0, column_index)
557
+
558
+ cols.get_range(column_index).style_index = @workbook.modify_border(get_col_style(column_index), direction, weight)
559
+
560
+ sheet_data.rows.each { |row|
561
+ c = row.cells[column_index]
562
+ c.change_border(direction, weight) unless c.nil?
563
+ }
564
+ end
565
+
566
+ def change_column_border_color(column_index, direction, color)
567
+ validate_workbook
568
+ ensure_cell_exists(0, column_index)
569
+ Color.validate_color(color)
570
+
571
+ cols.get_range(column_index).style_index = @workbook.modify_border_color(get_col_style(column_index), direction, color)
572
+
573
+ sheet_data.rows.each { |row|
574
+ c = row.cells[column_index]
575
+ c.change_border_color(direction, color) unless c.nil?
576
+ }
577
+ end
578
+
579
+ def change_row_alignment(row, &block)
580
+ validate_workbook
581
+ validate_nonnegative(row)
582
+ ensure_cell_exists(row)
583
+
584
+ sheet_data.rows[row].style_index = @workbook.modify_alignment(get_row_style(row), &block)
585
+
586
+ sheet_data[row].cells.each { |c|
587
+ next if c.nil?
588
+ c.style_index = @workbook.modify_alignment(c.style_index, &block)
589
+ }
590
+ end
591
+
592
+ def change_column_alignment(column_index, &block)
593
+ validate_workbook
594
+ ensure_cell_exists(0, column_index)
595
+
596
+ cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
597
+ # Excel gets confused if width is not explicitly set for a column that had alignment changes
598
+ change_column_width(column_index) if get_column_width_raw(column_index).nil?
599
+
600
+ sheet_data.rows.each { |row|
601
+ c = row[column_index]
602
+ next if c.nil?
603
+ c.style_index = @workbook.modify_alignment(c.style_index, &block)
604
+ }
605
+ end
606
+
607
+ # Merges cells within a rectangular area
608
+ def merge_cells(start_row, start_col, end_row, end_col)
609
+ validate_workbook
610
+
611
+ self.merged_cells ||= RubyXL::MergedCells.new
612
+ # TODO: add validation to make sure ranges are not intersecting with existing ones
613
+ merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
614
+ end
615
+ end
616
+
617
+ RubyXL::Worksheet.include(RubyXL::WorksheetConvenienceMethods)
618
+ end