rubyXL 3.3.33 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24ee840c0b843c7ac38c7ee1eadd5918c2151284fe45125a3bb340b6cf15c5cb
4
- data.tar.gz: e17613eaf073dd282955dc30a43084e65a9e48cdd2d9048d0148777ac21c0d70
3
+ metadata.gz: 871a2a772d8b6018c0fb567084285deffb0ebbc876859c2b88894e3e4e1a13b3
4
+ data.tar.gz: afe52938bb62c6481b824d2559cb926622d09e919a8afa938f08c187f4f0b9a4
5
5
  SHA512:
6
- metadata.gz: b8cce29f230a5c57f3fd4873e28c510b13694775ace5c5708d06620f79d9fba85c601d123273f4099cfb3d8322a00b60c05c509770ee48a5645a28c21479f723
7
- data.tar.gz: bef3148de242c914daf807db50fb5199b9654bcaf97cb9b8df84a7dca2a679051648eb12353c68e342597287d538b69ee22524ee5564a4cdc7f85ec8d9065527
6
+ metadata.gz: 803f1f0c47ffe14707804649e4e3b1ca18bb6ab4e3222c2519ecb9c0084139bb35a6f943f5301a65a6aca482fa921b85dc6483ae02184884953552117a821314
7
+ data.tar.gz: 8d24e24c5f016b4659d0672a7fc42c0a4d048b880c9d9b1c620ccfbe459f9e8983513e5ef9cd4ae0e153497b650dad97e374368cd9ad834525bb75494d336d34
data/README.rdoc CHANGED
@@ -15,6 +15,18 @@ Please note that proprietary binary +xls+ format is *not* supported.
15
15
  == To Use:
16
16
  require 'rubyXL' # Assuming rubygems is already required
17
17
 
18
+ === Convenience methods
19
+
20
+ Starting with version 3.4.0, the main data structure has been separated from the convenience methods that provide access to individual features of the +xlsx+ format, in order to decrease the memory footprint. If you intend to use these features, you will need to additionally include the respective files:
21
+ require 'rubyXL/convenience_methods/cell'
22
+ require 'rubyXL/convenience_methods/color'
23
+ require 'rubyXL/convenience_methods/font'
24
+ require 'rubyXL/convenience_methods/workbook'
25
+ require 'rubyXL/convenience_methods/worksheet'
26
+
27
+ If you do not care about your RAM usage, just include them all at once by adding the following line to your code so it can continue operating just as before:
28
+ require 'rubyXL/convenience_methods'
29
+
18
30
  === Parsing an existing workbook
19
31
  workbook = RubyXL::Parser.parse("path/to/Excel/file.xlsx")
20
32
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.33
1
+ 3.4.0
@@ -1,1301 +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 && color.get_rgb(self)
124
- color && color.to_s || 'ffffff'
125
- end
126
-
127
- def register_new_fill(new_fill, old_xf)
128
- new_xf = old_xf.dup
129
- new_xf.apply_fill = true
130
- new_xf.fill_id = fills.find_index { |x| x == new_fill } # Reuse existing fill, if it exists
131
- new_xf.fill_id ||= fills.size # If this fill has never existed before, add it to collection.
132
- fills[new_xf.fill_id] = new_fill
133
- new_xf
134
- end
135
-
136
- def register_new_font(new_font, old_xf)
137
- new_xf = old_xf.dup
138
- new_xf.font_id = fonts.find_index { |x| x == new_font } # Reuse existing font, if it exists
139
- new_xf.font_id ||= fonts.size # If this font has never existed before, add it to collection.
140
- fonts[new_xf.font_id] = new_font
141
- new_xf.apply_font = true
142
- new_xf
143
- end
144
-
145
- def register_new_xf(new_xf)
146
- new_xf_id = cell_xfs.find_index { |xf| xf == new_xf } # Reuse existing XF, if it exists
147
- new_xf_id ||= cell_xfs.size # If this XF has never existed before, add it to collection.
148
- cell_xfs[new_xf_id] = new_xf
149
- new_xf_id
150
- end
151
-
152
- def modify_alignment(style_index, &block)
153
- xf = cell_xfs[style_index || 0].dup
154
- xf.alignment = xf.alignment.dup || RubyXL::Alignment.new
155
- yield(xf.alignment)
156
- xf.apply_alignment = true
157
-
158
- register_new_xf(xf)
159
- end
160
-
161
- def modify_fill(style_index, rgb)
162
- xf = cell_xfs[style_index || 0].dup
163
- new_fill = RubyXL::Fill.new(:pattern_fill =>
164
- RubyXL::PatternFill.new(:pattern_type => 'solid',
165
- :fg_color => RubyXL::Color.new(:rgb => rgb)))
166
- register_new_xf(register_new_fill(new_fill, xf))
167
- end
168
-
169
- def modify_border(style_index, direction, weight)
170
- xf = cell_xfs[style_index || 0].dup
171
- new_border = borders[xf.border_id || 0].dup
172
-
173
- edge = new_border.send(direction)
174
- new_border.send("#{direction}=", edge.dup) if edge
175
-
176
- new_border.set_edge_style(direction, weight)
177
-
178
- xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
179
- xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
180
- borders[xf.border_id] = new_border
181
- xf.apply_border = true
182
-
183
- register_new_xf(xf)
184
- end
185
-
186
- def modify_border_color(style_index, direction, color)
187
- xf = cell_xfs[style_index || 0].dup
188
- new_border = borders[xf.border_id || 0].dup
189
- new_border.set_edge_color(direction, color)
190
-
191
- xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
192
- xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
193
- borders[xf.border_id] = new_border
194
- xf.apply_border = true
195
-
196
- register_new_xf(xf)
197
- end
198
-
199
- # Calculate password hash from string for use in 'password' fields.
200
- # https://www.openoffice.org/sc/excelfileformat.pdf
201
- def password_hash(pwd)
202
- hsh = 0
203
- pwd.reverse.each_char { |c|
204
- hsh = hsh ^ c.ord
205
- hsh = hsh << 1
206
- hsh -= 0x7fff if hsh > 0x7fff
207
- }
208
-
209
- (hsh ^ pwd.length ^ 0xCE4B).to_s(16)
210
- end
211
- end
212
-
213
-
214
- module WorksheetConvenienceMethods
215
- NAME = 0
216
- SIZE = 1
217
- COLOR = 2
218
- ITALICS = 3
219
- BOLD = 4
220
- UNDERLINE = 5
221
- STRIKETHROUGH = 6
222
-
223
- def insert_cell(row = 0, col = 0, data = nil, formula = nil, shift = nil)
224
- validate_workbook
225
- ensure_cell_exists(row, col)
226
-
227
- case shift
228
- when nil then # No shifting at all
229
- when :right then
230
- sheet_data.rows[row].insert_cell_shift_right(nil, col)
231
- when :down then
232
- add_row(sheet_data.size, :cells => Array.new(sheet_data.rows[row].size))
233
- (sheet_data.size - 1).downto(row+1) { |index|
234
- sheet_data.rows[index].cells[col] = sheet_data.rows[index-1].cells[col]
235
- }
236
- else
237
- raise 'invalid shift option'
238
- end
239
-
240
- return add_cell(row, col, data, formula)
241
- end
242
-
243
- # by default, only sets cell to nil
244
- # if :left is specified, method will shift row contents to the right of the deleted cell to the left
245
- # if :up is specified, method will shift column contents below the deleted cell upward
246
- def delete_cell(row_index = 0, column_index=0, shift=nil)
247
- validate_workbook
248
- validate_nonnegative(row_index)
249
- validate_nonnegative(column_index)
250
-
251
- row = sheet_data[row_index]
252
- old_cell = row && row[column_index]
253
-
254
- case shift
255
- when nil then
256
- row.cells[column_index] = nil if row
257
- when :left then
258
- row.delete_cell_shift_left(column_index) if row
259
- when :up then
260
- (row_index...(sheet_data.size - 1)).each { |index|
261
- c = sheet_data.rows[index].cells[column_index] = sheet_data.rows[index + 1].cells[column_index]
262
- c.row -= 1 if c.is_a?(Cell)
263
- }
264
- else
265
- raise 'invalid shift option'
266
- end
267
-
268
- return old_cell
269
- end
270
-
271
- # Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!)
272
- # NOTE: use of this method will break formulas which reference cells which are being "pushed down"
273
- def insert_row(row_index = 0)
274
- validate_workbook
275
- ensure_cell_exists(row_index)
276
-
277
- old_row = new_cells = nil
278
-
279
- if row_index > 0 then
280
- old_row = sheet_data.rows[row_index - 1]
281
- if old_row then
282
- new_cells = old_row.cells.collect { |c|
283
- if c.nil? then nil
284
- else nc = RubyXL::Cell.new(:style_index => c.style_index)
285
- nc.worksheet = self
286
- nc
287
- end
288
- }
289
- end
290
- end
291
-
292
- row0 = sheet_data.rows[0]
293
- new_cells ||= Array.new((row0 && row0.cells.size) || 0)
294
-
295
- sheet_data.rows.insert(row_index, nil)
296
- new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
297
-
298
- # Update row values for all rows below
299
- row_index.upto(sheet_data.rows.size - 1) { |r|
300
- row = sheet_data.rows[r]
301
- next if row.nil?
302
- row.cells.each_with_index { |cell, c|
303
- next if cell.nil?
304
- cell.r = RubyXL::Reference.new(r, c)
305
- }
306
- }
307
-
308
- return new_row
309
- end
310
-
311
- def delete_row(row_index=0)
312
- validate_workbook
313
- validate_nonnegative(row_index)
314
-
315
- deleted = sheet_data.rows.delete_at(row_index)
316
-
317
- # Update row number of each cell
318
- row_index.upto(sheet_data.size - 1) { |index|
319
- row = sheet_data[index]
320
- row && row.cells.each{ |c| c.row -= 1 unless c.nil? }
321
- }
322
-
323
- return deleted
324
- end
325
-
326
- # Inserts column at +column_index+, pushes everything right, takes styles from column to left
327
- # NOTE: use of this method will break formulas which reference cells which are being "pushed right"
328
- def insert_column(column_index = 0)
329
- validate_workbook
330
- ensure_cell_exists(0, column_index)
331
-
332
- old_range = cols.get_range(column_index)
333
-
334
- #go through each cell in column
335
- sheet_data.rows.each_with_index { |row, row_index|
336
- old_cell = row[column_index]
337
- c = nil
338
-
339
- if old_cell && old_cell.style_index != 0 &&
340
- old_range && old_range.style_index != old_cell.style_index then
341
-
342
- c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
343
- :row => row_index, :column => column_index,
344
- :datatype => RubyXL::DataType::SHARED_STRING)
345
- end
346
-
347
- row.insert_cell_shift_right(c, column_index)
348
- }
349
-
350
- cols.insert_column(column_index)
351
-
352
- # TODO: update column numbers
353
- end
354
-
355
- def delete_column(column_index = 0)
356
- validate_workbook
357
- validate_nonnegative(column_index)
358
-
359
- # Delete column
360
- sheet_data.rows.each { |row| row.cells.delete_at(column_index) }
361
-
362
- # Update column numbers for cells to the right of the deleted column
363
- sheet_data.rows.each_with_index { |row, row_index|
364
- row.cells.each_with_index { |c, ci|
365
- c.column = ci if c.is_a?(Cell)
366
- }
367
- }
368
-
369
- cols.each { |range| range.delete_column(column_index) }
370
- end
371
-
372
- def get_row_style(row_index)
373
- row = sheet_data.rows[row_index]
374
- (row && row.style_index) || 0
375
- end
376
-
377
- def get_row_fill(row = 0)
378
- (row = sheet_data.rows[row]) && row.get_fill_color
379
- end
380
-
381
- def get_row_font_name(row = 0)
382
- (font = row_font(row)) && font.get_name
383
- end
384
-
385
- def get_row_font_size(row = 0)
386
- (font = row_font(row)) && font.get_size
387
- end
388
-
389
- def get_row_font_color(row = 0)
390
- font = row_font(row)
391
- color = font && font.color
392
- color && (color.rgb || '000000')
393
- end
394
-
395
- def is_row_italicized(row = 0)
396
- (font = row_font(row)) && font.is_italic
397
- end
398
-
399
- def is_row_bolded(row = 0)
400
- (font = row_font(row)) && font.is_bold
401
- end
402
-
403
- def is_row_underlined(row = 0)
404
- (font = row_font(row)) && font.is_underlined
405
- end
406
-
407
- def is_row_struckthrough(row = 0)
408
- (font = row_font(row)) && font.is_strikethrough
409
- end
410
-
411
- def get_row_height(row = 0)
412
- validate_workbook
413
- validate_nonnegative(row)
414
- row = sheet_data.rows[row]
415
- row && row.ht || RubyXL::Row::DEFAULT_HEIGHT
416
- end
417
-
418
- def get_row_border(row, border_direction)
419
- validate_workbook
420
-
421
- border = @workbook.borders[get_row_xf(row).border_id]
422
- border && border.get_edge_style(border_direction)
423
- end
424
-
425
- def get_row_border_color(row, border_direction)
426
- validate_workbook
427
-
428
- border = @workbook.borders[get_row_xf(row).border_id]
429
- border && border.get_edge_color(border_direction)
430
- end
431
-
432
- def row_font(row)
433
- (row = sheet_data.rows[row]) && row.get_font
434
- end
435
-
436
- def get_row_alignment(row, is_horizontal)
437
- validate_workbook
438
-
439
- xf_obj = get_row_xf(row)
440
- return nil if xf_obj.alignment.nil?
441
-
442
- if is_horizontal then return xf_obj.alignment.horizontal
443
- else return xf_obj.alignment.vertical
444
- end
445
- end
446
-
447
- def get_cols_style_index(column_index)
448
- validate_nonnegative(column_index)
449
- range = cols.locate_range(column_index)
450
- (range && range.style_index) || 0
451
- end
452
-
453
- def get_column_font_name(col = 0)
454
- font = column_font(col)
455
- font && font.get_name
456
- end
457
-
458
- def get_column_font_size(col = 0)
459
- font = column_font(col)
460
- font && font.get_size
461
- end
462
-
463
- def get_column_font_color(col = 0)
464
- font = column_font(col)
465
- font && (font.get_rgb_color || '000000')
466
- end
467
-
468
- def is_column_italicized(col = 0)
469
- font = column_font(col)
470
- font && font.is_italic
471
- end
472
-
473
- def is_column_bolded(col = 0)
474
- font = column_font(col)
475
- font && font.is_bold
476
- end
477
-
478
- def is_column_underlined(col = 0)
479
- font = column_font(col)
480
- font && font.is_underlined
481
- end
482
-
483
- def is_column_struckthrough(col = 0)
484
- font = column_font(col)
485
- font && font.is_strikethrough
486
- end
487
-
488
- # Get raw column width value as stored in the file
489
- def get_column_width_raw(column_index = 0)
490
- validate_workbook
491
- validate_nonnegative(column_index)
492
-
493
- range = cols.locate_range(column_index)
494
- range && range.width
495
- end
496
-
497
- # Get column width measured in number of digits, as per
498
- # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
499
- def get_column_width(column_index = 0)
500
- width = get_column_width_raw(column_index)
501
- return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
502
- (width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
503
- end
504
-
505
- # Set raw column width value
506
- def change_column_width_raw(column_index, width)
507
- validate_workbook
508
- ensure_cell_exists(0, column_index)
509
- range = cols.get_range(column_index)
510
- range.width = width
511
- range.custom_width = true
512
- end
513
-
514
- # Get column width measured in number of digits, as per
515
- # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
516
- def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
517
- change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
518
- end
519
-
520
- # Helper method to get the style index for a column
521
- def get_col_style(column_index)
522
- range = cols.locate_range(column_index)
523
- (range && range.style_index) || 0
524
- end
525
-
526
- def get_column_fill(col=0)
527
- validate_workbook
528
- validate_nonnegative(col)
529
-
530
- @workbook.get_fill_color(get_col_xf(col))
531
- end
532
-
533
- def change_column_fill(column_index, color_code = 'ffffff')
534
- validate_workbook
535
- RubyXL::Color.validate_color(color_code)
536
- ensure_cell_exists(0, column_index)
537
-
538
- cols.get_range(column_index).style_index = @workbook.modify_fill(get_col_style(column_index), color_code)
539
-
540
- sheet_data.rows.each { |row|
541
- c = row[column_index]
542
- c.change_fill(color_code) if c
543
- }
544
- end
545
-
546
- def get_column_border(col, border_direction)
547
- validate_workbook
548
-
549
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
550
- border = @workbook.borders[xf.border_id]
551
- border && border.get_edge_style(border_direction)
552
- end
553
-
554
- def get_column_border_color(col, border_direction)
555
- validate_workbook
556
-
557
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
558
- border = @workbook.borders[xf.border_id]
559
- border && border.get_edge_color(border_direction)
560
- end
561
-
562
- def column_font(col)
563
- validate_workbook
564
-
565
- @workbook.fonts[@workbook.cell_xfs[get_cols_style_index(col)].font_id]
566
- end
567
-
568
- def get_column_alignment(col, type)
569
- validate_workbook
570
-
571
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
572
- xf.alignment && xf.alignment.send(type)
573
- end
574
-
575
- def change_row_horizontal_alignment(row = 0, alignment = 'center')
576
- validate_workbook
577
- validate_nonnegative(row)
578
- change_row_alignment(row) { |a| a.horizontal = alignment }
579
- end
580
-
581
- def change_row_vertical_alignment(row = 0, alignment = 'center')
582
- validate_workbook
583
- validate_nonnegative(row)
584
- change_row_alignment(row) { |a| a.vertical = alignment }
585
- end
586
-
587
- def change_row_border(row, direction, weight)
588
- validate_workbook
589
- ensure_cell_exists(row)
590
-
591
- sheet_data.rows[row].style_index = @workbook.modify_border(get_row_style(row), direction, weight)
592
-
593
- sheet_data[row].cells.each { |c|
594
- c.change_border(direction, weight) unless c.nil?
595
- }
596
- end
597
-
598
- def change_row_border_color(row, direction, color = '000000')
599
- validate_workbook
600
- ensure_cell_exists(row)
601
- Color.validate_color(color)
602
-
603
- sheet_data.rows[row].style_index = @workbook.modify_border_color(get_row_style(row), direction, color)
604
-
605
- sheet_data[row].cells.each { |c|
606
- c.change_border_color(direction, color) unless c.nil?
607
- }
608
- end
609
-
610
- def change_row_fill(row_index = 0, rgb = 'ffffff')
611
- validate_workbook
612
- ensure_cell_exists(row_index)
613
- Color.validate_color(rgb)
614
-
615
- sheet_data.rows[row_index].style_index = @workbook.modify_fill(get_row_style(row_index), rgb)
616
- sheet_data[row_index].cells.each { |c| c.change_fill(rgb) unless c.nil? }
617
- end
618
-
619
- # Helper method to update the row styles array
620
- # change_type - NAME or SIZE or COLOR etc
621
- # main method to change font, called from each separate font mutator method
622
- def change_row_font(row_index, change_type, arg, font)
623
- validate_workbook
624
- ensure_cell_exists(row_index)
625
-
626
- xf = workbook.register_new_font(font, get_row_xf(row_index))
627
- row = sheet_data[row_index]
628
- row.style_index = workbook.register_new_xf(xf)
629
- row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
630
- end
631
-
632
- def change_row_font_name(row = 0, font_name = 'Verdana')
633
- ensure_cell_exists(row)
634
- font = row_font(row).dup
635
- font.set_name(font_name)
636
- change_row_font(row, Worksheet::NAME, font_name, font)
637
- end
638
-
639
- def change_row_font_size(row = 0, font_size=10)
640
- ensure_cell_exists(row)
641
- font = row_font(row).dup
642
- font.set_size(font_size)
643
- change_row_font(row, Worksheet::SIZE, font_size, font)
644
- end
645
-
646
- def change_row_font_color(row = 0, font_color = '000000')
647
- ensure_cell_exists(row)
648
- Color.validate_color(font_color)
649
- font = row_font(row).dup
650
- font.set_rgb_color(font_color)
651
- change_row_font(row, Worksheet::COLOR, font_color, font)
652
- end
653
-
654
- def change_row_italics(row = 0, italicized = false)
655
- ensure_cell_exists(row)
656
- font = row_font(row).dup
657
- font.set_italic(italicized)
658
- change_row_font(row, Worksheet::ITALICS, italicized, font)
659
- end
660
-
661
- def change_row_bold(row = 0, bolded = false)
662
- ensure_cell_exists(row)
663
- font = row_font(row).dup
664
- font.set_bold(bolded)
665
- change_row_font(row, Worksheet::BOLD, bolded, font)
666
- end
667
-
668
- def change_row_underline(row = 0, underlined=false)
669
- ensure_cell_exists(row)
670
- font = row_font(row).dup
671
- font.set_underline(underlined)
672
- change_row_font(row, Worksheet::UNDERLINE, underlined, font)
673
- end
674
-
675
- def change_row_strikethrough(row = 0, struckthrough=false)
676
- ensure_cell_exists(row)
677
- font = row_font(row).dup
678
- font.set_strikethrough(struckthrough)
679
- change_row_font(row, Worksheet::STRIKETHROUGH, struckthrough, font)
680
- end
681
-
682
- def change_row_height(row = 0, height = 10)
683
- validate_workbook
684
- ensure_cell_exists(row)
685
-
686
- c = sheet_data.rows[row]
687
- c.ht = height
688
- c.custom_height = true
689
- end
690
-
691
- # Helper method to update the fonts and cell styles array
692
- # main method to change font, called from each separate font mutator method
693
- def change_column_font(column_index, change_type, arg, font, xf)
694
- validate_workbook
695
- ensure_cell_exists(0, column_index)
696
-
697
- xf = workbook.register_new_font(font, xf)
698
- cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
699
-
700
- sheet_data.rows.each { |row|
701
- c = row && row[column_index]
702
- c.font_switch(change_type, arg) unless c.nil?
703
- }
704
- end
705
-
706
- def change_column_font_name(column_index = 0, font_name = 'Verdana')
707
- xf = get_col_xf(column_index)
708
- font = @workbook.fonts[xf.font_id].dup
709
- font.set_name(font_name)
710
- change_column_font(column_index, Worksheet::NAME, font_name, font, xf)
711
- end
712
-
713
- def change_column_font_size(column_index, font_size=10)
714
- xf = get_col_xf(column_index)
715
- font = @workbook.fonts[xf.font_id].dup
716
- font.set_size(font_size)
717
- change_column_font(column_index, Worksheet::SIZE, font_size, font, xf)
718
- end
719
-
720
- def change_column_font_color(column_index, font_color='000000')
721
- Color.validate_color(font_color)
722
-
723
- xf = get_col_xf(column_index)
724
- font = @workbook.fonts[xf.font_id].dup
725
- font.set_rgb_color(font_color)
726
- change_column_font(column_index, Worksheet::COLOR, font_color, font, xf)
727
- end
728
-
729
- def change_column_italics(column_index, italicized = false)
730
- xf = get_col_xf(column_index)
731
- font = @workbook.fonts[xf.font_id].dup
732
- font.set_italic(italicized)
733
- change_column_font(column_index, Worksheet::ITALICS, italicized, font, xf)
734
- end
735
-
736
- def change_column_bold(column_index, bolded = false)
737
- xf = get_col_xf(column_index)
738
- font = @workbook.fonts[xf.font_id].dup
739
- font.set_bold(bolded)
740
- change_column_font(column_index, Worksheet::BOLD, bolded, font, xf)
741
- end
742
-
743
- def change_column_underline(column_index, underlined = false)
744
- xf = get_col_xf(column_index)
745
- font = @workbook.fonts[xf.font_id].dup
746
- font.set_underline(underlined)
747
- change_column_font(column_index, Worksheet::UNDERLINE, underlined, font, xf)
748
- end
749
-
750
- def change_column_strikethrough(column_index, struckthrough=false)
751
- xf = get_col_xf(column_index)
752
- font = @workbook.fonts[xf.font_id].dup
753
- font.set_strikethrough(struckthrough)
754
- change_column_font(column_index, Worksheet::STRIKETHROUGH, struckthrough, font, xf)
755
- end
756
-
757
- def change_column_horizontal_alignment(column_index, alignment = 'center')
758
- change_column_alignment(column_index) { |a| a.horizontal = alignment }
759
- end
760
-
761
- def change_column_vertical_alignment(column_index, alignment = 'center')
762
- change_column_alignment(column_index) { |a| a.vertical = alignment }
763
- end
764
-
765
- def change_column_border(column_index, direction, weight)
766
- validate_workbook
767
- ensure_cell_exists(0, column_index)
768
-
769
- cols.get_range(column_index).style_index = @workbook.modify_border(get_col_style(column_index), direction, weight)
770
-
771
- sheet_data.rows.each { |row|
772
- c = row.cells[column_index]
773
- c.change_border(direction, weight) unless c.nil?
774
- }
775
- end
776
-
777
- def change_column_border_color(column_index, direction, color)
778
- validate_workbook
779
- ensure_cell_exists(0, column_index)
780
- Color.validate_color(color)
781
-
782
- cols.get_range(column_index).style_index = @workbook.modify_border_color(get_col_style(column_index), direction, color)
783
-
784
- sheet_data.rows.each { |row|
785
- c = row.cells[column_index]
786
- c.change_border_color(direction, color) unless c.nil?
787
- }
788
- end
789
-
790
- def change_row_alignment(row, &block)
791
- validate_workbook
792
- validate_nonnegative(row)
793
- ensure_cell_exists(row)
794
-
795
- sheet_data.rows[row].style_index = @workbook.modify_alignment(get_row_style(row), &block)
796
-
797
- sheet_data[row].cells.each { |c|
798
- next if c.nil?
799
- c.style_index = @workbook.modify_alignment(c.style_index, &block)
800
- }
801
- end
802
-
803
- def change_column_alignment(column_index, &block)
804
- validate_workbook
805
- ensure_cell_exists(0, column_index)
806
-
807
- cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
808
- # Excel gets confused if width is not explicitly set for a column that had alignment changes
809
- change_column_width(column_index) if get_column_width_raw(column_index).nil?
810
-
811
- sheet_data.rows.each { |row|
812
- c = row[column_index]
813
- next if c.nil?
814
- c.style_index = @workbook.modify_alignment(c.style_index, &block)
815
- }
816
- end
817
-
818
- # Merges cells within a rectangular area
819
- def merge_cells(start_row, start_col, end_row, end_col)
820
- validate_workbook
821
-
822
- self.merged_cells ||= RubyXL::MergedCells.new
823
- # TODO: add validation to make sure ranges are not intersecting with existing ones
824
- merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
825
- end
826
- end
827
-
828
- module CellConvenienceMethods
829
-
830
- def change_contents(data, formula_expression = nil)
831
- validate_worksheet
832
-
833
- if formula_expression then
834
- self.datatype = nil
835
- self.formula = RubyXL::Formula.new(:expression => formula_expression)
836
- else
837
- self.datatype = case data
838
- when Date, Numeric then nil
839
- else RubyXL::DataType::RAW_STRING
840
- end
841
- end
842
-
843
- data = workbook.date_to_num(data) if data.is_a?(Date)
844
-
845
- self.raw_value = data
846
- end
847
-
848
- def get_border(direction)
849
- validate_worksheet
850
- get_cell_border.get_edge_style(direction)
851
- end
852
-
853
- def get_border_color(direction)
854
- validate_worksheet
855
- get_cell_border.get_edge_color(direction)
856
- end
857
-
858
- def change_horizontal_alignment(alignment = 'center')
859
- validate_worksheet
860
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.horizontal = alignment }
861
- end
862
-
863
- def change_vertical_alignment(alignment = 'center')
864
- validate_worksheet
865
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.vertical = alignment }
866
- end
867
-
868
- def change_text_wrap(wrap = false)
869
- validate_worksheet
870
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.wrap_text = wrap }
871
- end
872
-
873
- def change_text_rotation(rot)
874
- validate_worksheet
875
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.text_rotation = rot }
876
- end
877
-
878
- def change_text_indent(indent)
879
- validate_worksheet
880
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.indent = indent }
881
- end
882
-
883
- def change_border(direction, weight)
884
- validate_worksheet
885
- self.style_index = workbook.modify_border(self.style_index, direction, weight)
886
- end
887
-
888
- def change_border_color(direction, color)
889
- validate_worksheet
890
- Color.validate_color(color)
891
- self.style_index = workbook.modify_border_color(self.style_index, direction, color)
892
- end
893
-
894
- def is_italicized()
895
- validate_worksheet
896
- get_cell_font.is_italic
897
- end
898
-
899
- def is_bolded()
900
- validate_worksheet
901
- get_cell_font.is_bold
902
- end
903
-
904
- def is_underlined()
905
- validate_worksheet
906
- get_cell_font.is_underlined
907
- end
908
-
909
- def is_struckthrough()
910
- validate_worksheet
911
- get_cell_font.is_strikethrough
912
- end
913
-
914
- def font_name()
915
- validate_worksheet
916
- get_cell_font.get_name
917
- end
918
-
919
- def font_size()
920
- validate_worksheet
921
- get_cell_font.get_size
922
- end
923
-
924
- def font_color()
925
- validate_worksheet
926
- get_cell_font.get_rgb_color || '000000'
927
- end
928
-
929
- def fill_color()
930
- validate_worksheet
931
- return workbook.get_fill_color(get_cell_xf)
932
- end
933
-
934
- def horizontal_alignment()
935
- validate_worksheet
936
- xf_obj = get_cell_xf
937
- return nil if xf_obj.alignment.nil?
938
- xf_obj.alignment.horizontal
939
- end
940
-
941
- def vertical_alignment()
942
- validate_worksheet
943
- xf_obj = get_cell_xf
944
- return nil if xf_obj.alignment.nil?
945
- xf_obj.alignment.vertical
946
- end
947
-
948
- def text_wrap()
949
- validate_worksheet
950
- xf_obj = get_cell_xf
951
- return nil if xf_obj.alignment.nil?
952
- xf_obj.alignment.wrap_text
953
- end
954
-
955
- def text_rotation
956
- validate_worksheet
957
- xf_obj = get_cell_xf
958
- return nil if xf_obj.alignment.nil?
959
- xf_obj.alignment.text_rotation
960
- end
961
-
962
- def text_indent()
963
- validate_worksheet
964
- xf_obj = get_cell_xf
965
- return nil if xf_obj.alignment.nil?
966
- xf_obj.alignment.indent
967
- end
968
-
969
- def set_number_format(format_code)
970
- new_xf = get_cell_xf.dup
971
- new_xf.num_fmt_id = workbook.stylesheet.register_number_format(format_code)
972
- new_xf.apply_number_format = true
973
- self.style_index = workbook.register_new_xf(new_xf)
974
- end
975
-
976
- # Changes fill color of cell
977
- def change_fill(rgb = 'ffffff')
978
- validate_worksheet
979
- Color.validate_color(rgb)
980
- self.style_index = workbook.modify_fill(self.style_index, rgb)
981
- end
982
-
983
- # Changes font name of cell
984
- def change_font_name(new_font_name = 'Verdana')
985
- validate_worksheet
986
-
987
- font = get_cell_font.dup
988
- font.set_name(new_font_name)
989
- update_font_references(font)
990
- end
991
-
992
- # Changes font size of cell
993
- def change_font_size(font_size = 10)
994
- validate_worksheet
995
- raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)
996
-
997
- font = get_cell_font.dup
998
- font.set_size(font_size)
999
- update_font_references(font)
1000
- end
1001
-
1002
- # Changes font color of cell
1003
- def change_font_color(font_color = '000000')
1004
- validate_worksheet
1005
- Color.validate_color(font_color)
1006
-
1007
- font = get_cell_font.dup
1008
- font.set_rgb_color(font_color)
1009
- update_font_references(font)
1010
- end
1011
-
1012
- # Changes font italics settings of cell
1013
- def change_font_italics(italicized = false)
1014
- validate_worksheet
1015
-
1016
- font = get_cell_font.dup
1017
- font.set_italic(italicized)
1018
- update_font_references(font)
1019
- end
1020
-
1021
- # Changes font bold settings of cell
1022
- def change_font_bold(bolded = false)
1023
- validate_worksheet
1024
-
1025
- font = get_cell_font.dup
1026
- font.set_bold(bolded)
1027
- update_font_references(font)
1028
- end
1029
-
1030
- # Changes font underline settings of cell
1031
- def change_font_underline(underlined = false)
1032
- validate_worksheet
1033
-
1034
- font = get_cell_font.dup
1035
- font.set_underline(underlined)
1036
- update_font_references(font)
1037
- end
1038
-
1039
- def change_font_strikethrough(struckthrough = false)
1040
- validate_worksheet
1041
-
1042
- font = get_cell_font.dup
1043
- font.set_strikethrough(struckthrough)
1044
- update_font_references(font)
1045
- end
1046
-
1047
- # Helper method to update the font array and xf array
1048
- def update_font_references(modified_font)
1049
- xf = workbook.register_new_font(modified_font, get_cell_xf)
1050
- self.style_index = workbook.register_new_xf(xf)
1051
- end
1052
- private :update_font_references
1053
-
1054
- # Performs correct modification based on what type of change_type is specified
1055
- def font_switch(change_type, arg)
1056
- case change_type
1057
- when Worksheet::NAME then change_font_name(arg)
1058
- when Worksheet::SIZE then change_font_size(arg)
1059
- when Worksheet::COLOR then change_font_color(arg)
1060
- when Worksheet::ITALICS then change_font_italics(arg)
1061
- when Worksheet::BOLD then change_font_bold(arg)
1062
- when Worksheet::UNDERLINE then change_font_underline(arg)
1063
- when Worksheet::STRIKETHROUGH then change_font_strikethrough(arg)
1064
- else raise 'Invalid change_type'
1065
- end
1066
- end
1067
-
1068
- =begin
1069
- def add_hyperlink(l)
1070
- worksheet.hyperlinks ||= RubyXL::Hyperlinks.new
1071
- worksheet.hyperlinks << RubyXL::Hyperlink.new(:ref => self.r, :location => l)
1072
- # define_attribute(:'r:id', :string)
1073
- # define_attribute(:location, :string)
1074
- # define_attribute(:tooltip, :string)
1075
- # define_attribute(:display, :string)
1076
-
1077
- end
1078
-
1079
- def add_shared_string(str)
1080
- self.datatype = RubyXL::DataType::SHARED_STRING
1081
- self.raw_value = @workbook.shared_strings_container.add(str)
1082
- end
1083
- =end
1084
-
1085
- end
1086
-
1087
- module FontConvenienceMethods
1088
- # Funny enough, but presence of <i> without value (equivalent to `val == nul`) means "italic = true"!
1089
- # Same is true for bold, strikethrough, etc
1090
- def is_italic
1091
- i && (i.val != false)
1092
- end
1093
-
1094
- def is_bold
1095
- b && (b.val != false)
1096
- end
1097
-
1098
- def is_underlined
1099
- u && (u.val != false)
1100
- end
1101
-
1102
- def is_strikethrough
1103
- strike && (strike.val != false)
1104
- end
1105
-
1106
- def get_name
1107
- name && name.val
1108
- end
1109
-
1110
- def get_size
1111
- sz && sz.val
1112
- end
1113
-
1114
- def get_rgb_color
1115
- color && color.rgb
1116
- end
1117
-
1118
- def set_italic(val)
1119
- self.i = RubyXL::BooleanValue.new(:val => val)
1120
- end
1121
-
1122
- def set_bold(val)
1123
- self.b = RubyXL::BooleanValue.new(:val => val)
1124
- end
1125
-
1126
- def set_underline(val)
1127
- self.u = RubyXL::BooleanValue.new(:val => val)
1128
- end
1129
-
1130
- def set_strikethrough(val)
1131
- self.strike = RubyXL::BooleanValue.new(:val => val)
1132
- end
1133
-
1134
- def set_name(val)
1135
- self.name = RubyXL::StringValue.new(:val => val)
1136
- end
1137
-
1138
- def set_size(val)
1139
- self.sz = RubyXL::FloatValue.new(:val => val)
1140
- end
1141
-
1142
- def set_rgb_color(font_color)
1143
- self.color = RubyXL::Color.new(:rgb => font_color.to_s)
1144
- end
1145
- end
1146
-
1147
- module ColorConvenienceMethods
1148
-
1149
- def get_rgb(workbook)
1150
- if rgb then
1151
- return rgb
1152
- elsif theme then
1153
- theme_color = workbook.theme.get_theme_color(theme)
1154
- rgb_color = theme_color && theme_color.a_srgb_clr
1155
- color_value = rgb_color && rgb_color.val
1156
- return nil if color_value.nil?
1157
-
1158
- RubyXL::RgbColor.parse(color_value).to_hls.apply_tint(tint).to_rgb.to_s
1159
- end
1160
- end
1161
-
1162
- end
1163
-
1164
- module ColorConvenienceClasses
1165
- # https://ciintelligence.blogspot.com/2012/02/converting-excel-theme-color-and-tint.html
1166
- class RgbColor
1167
- attr_accessor :r, :g, :b, :a
1168
-
1169
- def to_hls
1170
- hls_color = HlsColor.new
1171
-
1172
- # Note that we are overriding accessors with local vars here:
1173
- r = self.r / 255.0
1174
- g = self.g / 255.0
1175
- b = self.b / 255.0
1176
-
1177
- hls_color.a = (self.a || 0) / 255.0
1178
-
1179
- min = [r, g, b].min
1180
- max = [r, g, b].max
1181
- delta = max - min
1182
-
1183
- if (max == min) then
1184
- hls_color.h = hls_color.s = 0
1185
- hls_color.l = max
1186
- return hls_color
1187
- end
1188
-
1189
- hls_color.l = (min + max) / 2
1190
-
1191
- if (hls_color.l < 0.5) then
1192
- hls_color.s = delta / (max + min);
1193
- else
1194
- hls_color.s = delta / (2.0 - max - min);
1195
- end
1196
-
1197
- hls_color.h = (g - b) / delta if (r == max)
1198
- hls_color.h = 2.0 + (b - r) / delta if (g == max)
1199
- hls_color.h = 4.0 + (r - g) / delta if (b == max)
1200
-
1201
- hls_color.h *= 60;
1202
- hls_color.h += 360 if hls_color.h < 0
1203
-
1204
- hls_color
1205
- end
1206
-
1207
- def self.parse(str)
1208
- r, g, b, a = str.unpack("A2A2A2A2")
1209
-
1210
- rgb_color = RgbColor.new
1211
- rgb_color.r = r && r.to_i(16)
1212
- rgb_color.g = g && g.to_i(16)
1213
- rgb_color.b = b && b.to_i(16)
1214
- rgb_color.a = a && a.to_i(16)
1215
-
1216
- rgb_color
1217
- end
1218
-
1219
- def to_s
1220
- str = r.to_s(16) + g.to_s(16) + b.to_s(16)
1221
- str += a.to_s(16) if a && a != 0
1222
- str
1223
- end
1224
-
1225
- end
1226
-
1227
- class HlsColor
1228
- attr_accessor :h, :l, :s, :a
1229
-
1230
- def to_rgb
1231
- rgb_color = RgbColor.new
1232
-
1233
- r = g = b = l
1234
-
1235
- if s != 0 then
1236
- t1 = nil
1237
-
1238
- if l < 0.5 then
1239
- t1 = l * (1.0 + s)
1240
- else
1241
- t1 = l + s - (l * s)
1242
- end
1243
-
1244
- t2 = 2.0 * l - t1;
1245
- h = self.h / 360.0
1246
-
1247
- t_r = h + (1.0 / 3.0)
1248
- r = set_color(t1, t2, t_r)
1249
-
1250
- t_g = h;
1251
- g = set_color(t1, t2, t_g)
1252
-
1253
- t_b = h - (1.0 / 3.0);
1254
- b = set_color(t1, t2, t_b)
1255
- end
1256
-
1257
- rgb_color.r = (r * 255).round(0).to_i
1258
- rgb_color.g = (g * 255).round(0).to_i
1259
- rgb_color.b = (b * 255).round(0).to_i
1260
-
1261
- rgb_color.a = (a * 255).round(0).to_i
1262
-
1263
- rgb_color
1264
- end
1265
-
1266
- def set_color(t1, t2, t3)
1267
- color = 0
1268
-
1269
- t3 += 1.0 if (t3 < 0)
1270
- t3 -= 1.0 if (t3 > 1)
1271
-
1272
- if (6.0 * t3 < 1) then
1273
- color = t2 + (t1 - t2) * 6.0 * t3;
1274
- elsif (2.0 * t3 < 1) then
1275
- color = t1;
1276
- elsif (3.0 * t3 < 2) then
1277
- color = t2 + (t1 - t2) * ((2.0 / 3.0) - t3) * 6.0;
1278
- else
1279
- color = t2;
1280
- end
1281
-
1282
- color
1283
- end
1284
- private :set_color
1285
-
1286
- def apply_tint(tint)
1287
- return self if tint.nil? || tint == 0
1288
-
1289
- if tint < 0 then
1290
- self.l = l * (1.0 + tint);
1291
- else
1292
- self.l = l * (1.0 - tint) + tint;
1293
- end
1294
-
1295
- self
1296
- end
1297
-
1298
- end
1299
- end
1300
-
1301
- 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'