rubyXL 3.3.33 → 3.4.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (463) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +60 -0
  3. data/Gemfile +9 -8
  4. data/Gemfile.lock +124 -0
  5. data/LICENSE.txt +1 -1
  6. data/README.rdoc +46 -22
  7. data/Rakefile +29 -29
  8. data/VERSION +1 -1
  9. data/lib/rubyXL/cell.rb +2 -29
  10. data/lib/rubyXL/convenience_methods/cell.rb +276 -0
  11. data/lib/rubyXL/convenience_methods/color.rb +156 -0
  12. data/lib/rubyXL/convenience_methods/font.rb +63 -0
  13. data/lib/rubyXL/convenience_methods/workbook.rb +141 -0
  14. data/lib/rubyXL/convenience_methods/worksheet.rb +714 -0
  15. data/lib/rubyXL/convenience_methods.rb +5 -1301
  16. data/lib/rubyXL/objects/border.rb +0 -3
  17. data/lib/rubyXL/objects/calculation_chain.rb +2 -2
  18. data/lib/rubyXL/objects/cell_style.rb +1 -3
  19. data/lib/rubyXL/objects/chartsheet.rb +8 -12
  20. data/lib/rubyXL/objects/color.rb +3 -7
  21. data/lib/rubyXL/objects/column_range.rb +0 -3
  22. data/lib/rubyXL/objects/comments.rb +1 -4
  23. data/lib/rubyXL/objects/connection.rb +175 -0
  24. data/lib/rubyXL/objects/container_nodes.rb +1 -5
  25. data/lib/rubyXL/objects/content_types.rb +3 -6
  26. data/lib/rubyXL/objects/data_validation.rb +2 -2
  27. data/lib/rubyXL/objects/document_properties.rb +11 -15
  28. data/lib/rubyXL/objects/extensions.rb +0 -2
  29. data/lib/rubyXL/objects/external_links.rb +30 -8
  30. data/lib/rubyXL/objects/fill.rb +2 -5
  31. data/lib/rubyXL/objects/filters.rb +5 -7
  32. data/lib/rubyXL/objects/font.rb +2 -7
  33. data/lib/rubyXL/objects/formula.rb +3 -5
  34. data/lib/rubyXL/objects/ooxml_object.rb +26 -19
  35. data/lib/rubyXL/objects/query_table.rb +104 -0
  36. data/lib/rubyXL/objects/reference.rb +6 -8
  37. data/lib/rubyXL/objects/relationships.rb +13 -13
  38. data/lib/rubyXL/objects/root.rb +0 -2
  39. data/lib/rubyXL/objects/shared_strings.rb +3 -6
  40. data/lib/rubyXL/objects/sheet_common.rb +1 -3
  41. data/lib/rubyXL/objects/sheet_data.rb +38 -11
  42. data/lib/rubyXL/objects/simple_types.rb +16 -1
  43. data/lib/rubyXL/objects/storage.rb +51 -50
  44. data/lib/rubyXL/objects/stylesheet.rb +8 -15
  45. data/lib/rubyXL/objects/text.rb +5 -7
  46. data/lib/rubyXL/objects/theme.rb +5 -8
  47. data/lib/rubyXL/objects/workbook.rb +140 -33
  48. data/lib/rubyXL/objects/worksheet.rb +44 -31
  49. data/lib/rubyXL/parser.rb +1 -3
  50. data/lib/rubyXL/worksheet.rb +83 -91
  51. data/lib/rubyXL.rb +1 -1
  52. data/rdoc/README_rdoc.html +111 -126
  53. data/rdoc/RubyXL/AExtension.html +20 -60
  54. data/rdoc/RubyXL/AExtensionStorageArea.html +11 -17
  55. data/rdoc/RubyXL/ActiveX.html +19 -47
  56. data/rdoc/RubyXL/ActiveXBinary.html +11 -22
  57. data/rdoc/RubyXL/AdjustHandleList.html +12 -19
  58. data/rdoc/RubyXL/Alignment.html +12 -19
  59. data/rdoc/RubyXL/AlternateContent.html +11 -17
  60. data/rdoc/RubyXL/Authors.html +12 -19
  61. data/rdoc/RubyXL/AutoFilter.html +12 -19
  62. data/rdoc/RubyXL/AutoFilterColumn.html +12 -19
  63. data/rdoc/RubyXL/BinaryImageFile.html +11 -25
  64. data/rdoc/RubyXL/BodyProperties.html +12 -19
  65. data/rdoc/RubyXL/BooleanNode.html +11 -17
  66. data/rdoc/RubyXL/BooleanValue.html +11 -17
  67. data/rdoc/RubyXL/Border.html +24 -84
  68. data/rdoc/RubyXL/BorderEdge.html +19 -52
  69. data/rdoc/RubyXL/Borders.html +18 -39
  70. data/rdoc/RubyXL/Break.html +12 -19
  71. data/rdoc/RubyXL/BreakList.html +12 -19
  72. data/rdoc/RubyXL/CT_AdjPoint2D.html +12 -19
  73. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +12 -19
  74. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +12 -19
  75. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +12 -19
  76. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +12 -19
  77. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +12 -19
  78. data/rdoc/RubyXL/CT_Backdrop.html +12 -19
  79. data/rdoc/RubyXL/CT_Bevel.html +12 -19
  80. data/rdoc/RubyXL/CT_BiLevelEffect.html +12 -19
  81. data/rdoc/RubyXL/CT_BlendEffect.html +12 -19
  82. data/rdoc/RubyXL/CT_Blip.html +12 -19
  83. data/rdoc/RubyXL/CT_BlipFillProperties.html +12 -19
  84. data/rdoc/RubyXL/CT_BlurEffect.html +12 -19
  85. data/rdoc/RubyXL/CT_Camera.html +12 -19
  86. data/rdoc/RubyXL/CT_Color.html +12 -19
  87. data/rdoc/RubyXL/CT_ColorChangeEffect.html +12 -19
  88. data/rdoc/RubyXL/CT_ColorMapping.html +12 -19
  89. data/rdoc/RubyXL/CT_ColorScheme.html +12 -19
  90. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +12 -19
  91. data/rdoc/RubyXL/CT_ConnectionSite.html +12 -19
  92. data/rdoc/RubyXL/CT_ConnectionSiteList.html +12 -19
  93. data/rdoc/RubyXL/CT_DashStop.html +12 -19
  94. data/rdoc/RubyXL/CT_DashStopList.html +12 -19
  95. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +12 -19
  96. data/rdoc/RubyXL/CT_DuotoneEffect.html +12 -19
  97. data/rdoc/RubyXL/CT_EffectContainer.html +12 -19
  98. data/rdoc/RubyXL/CT_EffectList.html +12 -19
  99. data/rdoc/RubyXL/CT_EffectReference.html +12 -19
  100. data/rdoc/RubyXL/CT_EffectStyleItem.html +12 -19
  101. data/rdoc/RubyXL/CT_EffectStyleList.html +12 -19
  102. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +12 -19
  103. data/rdoc/RubyXL/CT_FillEffect.html +12 -19
  104. data/rdoc/RubyXL/CT_FillOverlayEffect.html +12 -19
  105. data/rdoc/RubyXL/CT_FillStyleList.html +12 -19
  106. data/rdoc/RubyXL/CT_FlatText.html +12 -19
  107. data/rdoc/RubyXL/CT_FontCollection.html +12 -19
  108. data/rdoc/RubyXL/CT_FontReference.html +12 -19
  109. data/rdoc/RubyXL/CT_GeomGuideList.html +12 -19
  110. data/rdoc/RubyXL/CT_GlowEffect.html +12 -19
  111. data/rdoc/RubyXL/CT_GradientFillProperties.html +12 -19
  112. data/rdoc/RubyXL/CT_GradientStop.html +12 -19
  113. data/rdoc/RubyXL/CT_GradientStopList.html +12 -19
  114. data/rdoc/RubyXL/CT_HSLEffect.html +12 -19
  115. data/rdoc/RubyXL/CT_HslColor.html +12 -19
  116. data/rdoc/RubyXL/CT_Hyperlink.html +12 -19
  117. data/rdoc/RubyXL/CT_InnerShadowEffect.html +12 -19
  118. data/rdoc/RubyXL/CT_LightRig.html +12 -19
  119. data/rdoc/RubyXL/CT_LineEndProperties.html +12 -19
  120. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +12 -19
  121. data/rdoc/RubyXL/CT_LineProperties.html +12 -19
  122. data/rdoc/RubyXL/CT_LineStyleList.html +12 -19
  123. data/rdoc/RubyXL/CT_LinearShadeProperties.html +12 -19
  124. data/rdoc/RubyXL/CT_LuminanceEffect.html +12 -19
  125. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +12 -19
  126. data/rdoc/RubyXL/CT_OuterShadowEffect.html +12 -19
  127. data/rdoc/RubyXL/CT_Path2D.html +12 -19
  128. data/rdoc/RubyXL/CT_Path2DArcTo.html +12 -19
  129. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +12 -19
  130. data/rdoc/RubyXL/CT_Path2DList.html +12 -19
  131. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +12 -19
  132. data/rdoc/RubyXL/CT_Path2DTo.html +12 -19
  133. data/rdoc/RubyXL/CT_PathShadeProperties.html +12 -19
  134. data/rdoc/RubyXL/CT_PatternFillProperties.html +12 -19
  135. data/rdoc/RubyXL/CT_Point3D.html +12 -19
  136. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +12 -19
  137. data/rdoc/RubyXL/CT_PresetColor.html +12 -19
  138. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +12 -19
  139. data/rdoc/RubyXL/CT_PresetShadowEffect.html +12 -19
  140. data/rdoc/RubyXL/CT_PresetTextShape.html +12 -19
  141. data/rdoc/RubyXL/CT_ReflectionEffect.html +12 -19
  142. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +12 -19
  143. data/rdoc/RubyXL/CT_RelativeRect.html +12 -19
  144. data/rdoc/RubyXL/CT_SRgbColor.html +12 -19
  145. data/rdoc/RubyXL/CT_ScRgbColor.html +12 -19
  146. data/rdoc/RubyXL/CT_Scene3D.html +12 -19
  147. data/rdoc/RubyXL/CT_SchemeColor.html +12 -19
  148. data/rdoc/RubyXL/CT_Shape3D.html +12 -19
  149. data/rdoc/RubyXL/CT_ShapeStyle.html +12 -19
  150. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +12 -19
  151. data/rdoc/RubyXL/CT_SphereCoords.html +12 -19
  152. data/rdoc/RubyXL/CT_StretchInfoProperties.html +12 -19
  153. data/rdoc/RubyXL/CT_StyleMatrix.html +12 -19
  154. data/rdoc/RubyXL/CT_StyleMatrixReference.html +12 -19
  155. data/rdoc/RubyXL/CT_SupplementalFont.html +12 -19
  156. data/rdoc/RubyXL/CT_SystemColor.html +12 -19
  157. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +12 -19
  158. data/rdoc/RubyXL/CT_TextBlipBullet.html +12 -19
  159. data/rdoc/RubyXL/CT_TextCharBullet.html +12 -19
  160. data/rdoc/RubyXL/CT_TextCharacterProperties.html +12 -19
  161. data/rdoc/RubyXL/CT_TextFont.html +12 -19
  162. data/rdoc/RubyXL/CT_TextListStyle.html +12 -19
  163. data/rdoc/RubyXL/CT_TextNormalAutofit.html +12 -19
  164. data/rdoc/RubyXL/CT_TextParagraphProperties.html +12 -19
  165. data/rdoc/RubyXL/CT_TextSpacing.html +12 -19
  166. data/rdoc/RubyXL/CT_TextTabStop.html +12 -19
  167. data/rdoc/RubyXL/CT_TextTabStopList.html +12 -19
  168. data/rdoc/RubyXL/CT_TileInfoProperties.html +12 -19
  169. data/rdoc/RubyXL/CT_TintEffect.html +12 -19
  170. data/rdoc/RubyXL/CT_Transform2D.html +12 -19
  171. data/rdoc/RubyXL/CT_TransformEffect.html +12 -19
  172. data/rdoc/RubyXL/CT_Vector3D.html +12 -19
  173. data/rdoc/RubyXL/CT_XYAdjustHandle.html +12 -19
  174. data/rdoc/RubyXL/CalculationChain.html +16 -45
  175. data/rdoc/RubyXL/CalculationChainCell.html +12 -19
  176. data/rdoc/RubyXL/CalculationProperties.html +12 -19
  177. data/rdoc/RubyXL/Cell.html +133 -209
  178. data/rdoc/RubyXL/CellConvenienceMethods.html +168 -522
  179. data/rdoc/RubyXL/CellExt.html +12 -19
  180. data/rdoc/RubyXL/CellSmartTag.html +12 -19
  181. data/rdoc/RubyXL/CellSmartTagProperty.html +12 -19
  182. data/rdoc/RubyXL/CellSmartTags.html +12 -19
  183. data/rdoc/RubyXL/CellStyle.html +12 -19
  184. data/rdoc/RubyXL/CellStyleXFs.html +18 -39
  185. data/rdoc/RubyXL/CellStyles.html +18 -39
  186. data/rdoc/RubyXL/CellValue.html +17 -38
  187. data/rdoc/RubyXL/CellWatch.html +12 -19
  188. data/rdoc/RubyXL/CellWatches.html +12 -19
  189. data/rdoc/RubyXL/CellXFs.html +19 -42
  190. data/rdoc/RubyXL/ChartColorsFile.html +11 -25
  191. data/rdoc/RubyXL/ChartFile.html +18 -49
  192. data/rdoc/RubyXL/ChartStyleFile.html +11 -25
  193. data/rdoc/RubyXL/ChartUserShapesFile.html +11 -25
  194. data/rdoc/RubyXL/Chartsheet.html +19 -68
  195. data/rdoc/RubyXL/ChartsheetPageSetup.html +12 -19
  196. data/rdoc/RubyXL/ChartsheetProperties.html +12 -19
  197. data/rdoc/RubyXL/ChartsheetProtection.html +12 -19
  198. data/rdoc/RubyXL/ChartsheetView.html +12 -19
  199. data/rdoc/RubyXL/ChartsheetViews.html +12 -19
  200. data/rdoc/RubyXL/Color.html +18 -55
  201. data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +18 -65
  202. data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +28 -88
  203. data/rdoc/RubyXL/ColorConvenienceClasses.html +9 -14
  204. data/rdoc/RubyXL/ColorConvenienceMethods.html +14 -33
  205. data/rdoc/RubyXL/ColorFilter.html +12 -19
  206. data/rdoc/RubyXL/ColorScale.html +12 -19
  207. data/rdoc/RubyXL/ColorSet.html +12 -19
  208. data/rdoc/RubyXL/Colors.html +12 -19
  209. data/rdoc/RubyXL/ColumnRange.html +22 -74
  210. data/rdoc/RubyXL/ColumnRanges.html +23 -83
  211. data/rdoc/RubyXL/Comment.html +12 -19
  212. data/rdoc/RubyXL/CommentList.html +12 -19
  213. data/rdoc/RubyXL/CommentsFile.html +17 -51
  214. data/rdoc/RubyXL/ConditionalFormatValue.html +12 -19
  215. data/rdoc/RubyXL/ConditionalFormatting.html +12 -19
  216. data/rdoc/RubyXL/ConditionalFormattingRule.html +12 -19
  217. data/rdoc/RubyXL/Connection.html +99 -0
  218. data/rdoc/RubyXL/ConnectionTable.html +99 -0
  219. data/rdoc/RubyXL/ConnectionTables.html +99 -0
  220. data/rdoc/RubyXL/ConnectionTextField.html +99 -0
  221. data/rdoc/RubyXL/ConnectionTextFields.html +99 -0
  222. data/rdoc/RubyXL/Connections.html +147 -0
  223. data/rdoc/RubyXL/ContentTypeDefault.html +11 -17
  224. data/rdoc/RubyXL/ContentTypeOverride.html +11 -17
  225. data/rdoc/RubyXL/ContentTypes.html +22 -63
  226. data/rdoc/RubyXL/ControlPropertiesFile.html +13 -22
  227. data/rdoc/RubyXL/CorePropertiesFile.html +34 -171
  228. data/rdoc/RubyXL/CustomColor.html +12 -19
  229. data/rdoc/RubyXL/CustomColorList.html +12 -19
  230. data/rdoc/RubyXL/CustomFilter.html +12 -19
  231. data/rdoc/RubyXL/CustomFilters.html +12 -19
  232. data/rdoc/RubyXL/CustomGeometry.html +12 -19
  233. data/rdoc/RubyXL/CustomProperties.html +12 -19
  234. data/rdoc/RubyXL/CustomPropertiesFile.html +11 -25
  235. data/rdoc/RubyXL/CustomProperty.html +12 -19
  236. data/rdoc/RubyXL/CustomPropertyFile.html +11 -25
  237. data/rdoc/RubyXL/CustomSheetView.html +12 -19
  238. data/rdoc/RubyXL/CustomSheetViews.html +12 -19
  239. data/rdoc/RubyXL/CustomWorkbookView.html +12 -19
  240. data/rdoc/RubyXL/CustomWorkbookViews.html +12 -19
  241. data/rdoc/RubyXL/CustomXMLFile.html +11 -22
  242. data/rdoc/RubyXL/DXF.html +12 -19
  243. data/rdoc/RubyXL/DXFs.html +12 -19
  244. data/rdoc/RubyXL/DataBar.html +12 -19
  245. data/rdoc/RubyXL/DataConsolidate.html +12 -19
  246. data/rdoc/RubyXL/DataConsolidationReference.html +12 -19
  247. data/rdoc/RubyXL/DataConsolidationReferences.html +12 -19
  248. data/rdoc/RubyXL/DataType.html +10 -39
  249. data/rdoc/RubyXL/DataValidation.html +12 -19
  250. data/rdoc/RubyXL/DataValidations.html +12 -19
  251. data/rdoc/RubyXL/DateGroupItem.html +12 -19
  252. data/rdoc/RubyXL/DefinedName.html +12 -19
  253. data/rdoc/RubyXL/DefinedNameExt.html +12 -19
  254. data/rdoc/RubyXL/DefinedNames.html +12 -19
  255. data/rdoc/RubyXL/DefinedNamesExt.html +12 -19
  256. data/rdoc/RubyXL/DocumentPropertiesFile.html +21 -68
  257. data/rdoc/RubyXL/DrawingFile.html +18 -49
  258. data/rdoc/RubyXL/DynamicFilter.html +12 -19
  259. data/rdoc/RubyXL/EmbeddedControl.html +12 -19
  260. data/rdoc/RubyXL/EmbeddedControls.html +12 -19
  261. data/rdoc/RubyXL/Extension.html +12 -19
  262. data/rdoc/RubyXL/ExtensionStorageArea.html +12 -19
  263. data/rdoc/RubyXL/Extents.html +12 -19
  264. data/rdoc/RubyXL/ExternalBook.html +12 -19
  265. data/rdoc/RubyXL/ExternalLinksFile.html +18 -49
  266. data/rdoc/RubyXL/ExternalReference.html +12 -19
  267. data/rdoc/RubyXL/ExternalReferences.html +12 -19
  268. data/rdoc/RubyXL/ExtraColorSchemeList.html +12 -19
  269. data/rdoc/RubyXL/FieldItem.html +12 -19
  270. data/rdoc/RubyXL/FileRecoveryProperties.html +12 -19
  271. data/rdoc/RubyXL/FileSharing.html +12 -19
  272. data/rdoc/RubyXL/FileVersion.html +12 -19
  273. data/rdoc/RubyXL/Fill.html +18 -39
  274. data/rdoc/RubyXL/Fills.html +18 -39
  275. data/rdoc/RubyXL/FilterContainer.html +12 -19
  276. data/rdoc/RubyXL/FloatNode.html +11 -17
  277. data/rdoc/RubyXL/FloatValue.html +11 -17
  278. data/rdoc/RubyXL/Font.html +21 -59
  279. data/rdoc/RubyXL/FontConvenienceMethods.html +48 -237
  280. data/rdoc/RubyXL/FontScheme.html +12 -19
  281. data/rdoc/RubyXL/Fonts.html +18 -39
  282. data/rdoc/RubyXL/Formula.html +12 -19
  283. data/rdoc/RubyXL/FunctionGroup.html +12 -19
  284. data/rdoc/RubyXL/FunctionGroups.html +12 -19
  285. data/rdoc/RubyXL/GenericStorageObject.html +21 -84
  286. data/rdoc/RubyXL/GradientFill.html +12 -19
  287. data/rdoc/RubyXL/HeaderFooterSettings.html +12 -19
  288. data/rdoc/RubyXL/Hyperlink.html +12 -19
  289. data/rdoc/RubyXL/HyperlinkRelFile.html +11 -22
  290. data/rdoc/RubyXL/Hyperlinks.html +12 -19
  291. data/rdoc/RubyXL/IconFilter.html +12 -19
  292. data/rdoc/RubyXL/IconSet.html +12 -19
  293. data/rdoc/RubyXL/IgnoredError.html +12 -19
  294. data/rdoc/RubyXL/IgnoredErrors.html +12 -19
  295. data/rdoc/RubyXL/IndexedColors.html +12 -19
  296. data/rdoc/RubyXL/InputCells.html +12 -19
  297. data/rdoc/RubyXL/IntegerNode.html +11 -17
  298. data/rdoc/RubyXL/IntegerValue.html +11 -17
  299. data/rdoc/RubyXL/LegacyCell.html +13 -66
  300. data/rdoc/RubyXL/LegacyWorksheet.html +25 -99
  301. data/rdoc/RubyXL/MRUColors.html +12 -19
  302. data/rdoc/RubyXL/MacrosFile.html +11 -25
  303. data/rdoc/RubyXL/MergedCell.html +12 -19
  304. data/rdoc/RubyXL/MergedCells.html +12 -19
  305. data/rdoc/RubyXL/NumFmt.html +12 -19
  306. data/rdoc/RubyXL/NumberFormat.html +18 -39
  307. data/rdoc/RubyXL/NumberFormats.html +18 -45
  308. data/rdoc/RubyXL/OLEObject.html +12 -19
  309. data/rdoc/RubyXL/OLEObjectFile.html +11 -25
  310. data/rdoc/RubyXL/OLEObjects.html +12 -19
  311. data/rdoc/RubyXL/OLESize.html +12 -19
  312. data/rdoc/RubyXL/OOXMLContainerObject.html +35 -132
  313. data/rdoc/RubyXL/OOXMLIgnored.html +19 -53
  314. data/rdoc/RubyXL/OOXMLObject.html +14 -25
  315. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +91 -183
  316. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +48 -185
  317. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +47 -200
  318. data/rdoc/RubyXL/OOXMLTopLevelObject.html +36 -133
  319. data/rdoc/RubyXL/OdbcOleDbProperties.html +99 -0
  320. data/rdoc/RubyXL/Offset.html +12 -19
  321. data/rdoc/RubyXL/OlapProperties.html +99 -0
  322. data/rdoc/RubyXL/OleItem.html +99 -0
  323. data/rdoc/RubyXL/OleItems.html +99 -0
  324. data/rdoc/RubyXL/OleLink.html +99 -0
  325. data/rdoc/RubyXL/OutlineProperties.html +12 -19
  326. data/rdoc/RubyXL/PageMargins.html +12 -19
  327. data/rdoc/RubyXL/PageSetup.html +12 -19
  328. data/rdoc/RubyXL/PageSetupProperties.html +12 -19
  329. data/rdoc/RubyXL/Pane.html +12 -19
  330. data/rdoc/RubyXL/Parser.html +22 -56
  331. data/rdoc/RubyXL/PatternFill.html +12 -19
  332. data/rdoc/RubyXL/PhoneticProperties.html +12 -19
  333. data/rdoc/RubyXL/PhoneticRun.html +12 -19
  334. data/rdoc/RubyXL/PivotArea.html +12 -19
  335. data/rdoc/RubyXL/PivotCache.html +12 -19
  336. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +13 -30
  337. data/rdoc/RubyXL/PivotCacheRecordsFile.html +11 -25
  338. data/rdoc/RubyXL/PivotCaches.html +12 -19
  339. data/rdoc/RubyXL/PivotReference.html +12 -19
  340. data/rdoc/RubyXL/PivotReferences.html +12 -19
  341. data/rdoc/RubyXL/PivotTableFile.html +13 -30
  342. data/rdoc/RubyXL/PivotTableSelection.html +12 -19
  343. data/rdoc/RubyXL/PresetGeometry.html +12 -19
  344. data/rdoc/RubyXL/PrintOptions.html +12 -19
  345. data/rdoc/RubyXL/PrinterSettingsFile.html +11 -25
  346. data/rdoc/RubyXL/ProtectedRange.html +12 -19
  347. data/rdoc/RubyXL/ProtectedRanges.html +12 -19
  348. data/rdoc/RubyXL/Protection.html +12 -19
  349. data/rdoc/RubyXL/QueryParameter.html +99 -0
  350. data/rdoc/RubyXL/QueryParameters.html +99 -0
  351. data/rdoc/RubyXL/QueryTable.html +155 -0
  352. data/rdoc/RubyXL/QueryTableDeletedField.html +99 -0
  353. data/rdoc/RubyXL/QueryTableDeletedFields.html +99 -0
  354. data/rdoc/RubyXL/QueryTableField.html +99 -0
  355. data/rdoc/RubyXL/QueryTableFields.html +99 -0
  356. data/rdoc/RubyXL/QueryTableRefresh.html +99 -0
  357. data/rdoc/RubyXL/RID.html +11 -17
  358. data/rdoc/RubyXL/RawOOXML.html +20 -60
  359. data/rdoc/RubyXL/Reference.html +62 -228
  360. data/rdoc/RubyXL/Relationship.html +11 -17
  361. data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +13 -32
  362. data/rdoc/RubyXL/RelationshipSupport.html +25 -120
  363. data/rdoc/RubyXL/RevisionPointer.html +12 -22
  364. data/rdoc/RubyXL/RichText.html +19 -39
  365. data/rdoc/RubyXL/RichTextRun.html +17 -38
  366. data/rdoc/RubyXL/Row.html +33 -168
  367. data/rdoc/RubyXL/RowExt.html +12 -19
  368. data/rdoc/RubyXL/RunProperties.html +12 -19
  369. data/rdoc/RubyXL/Scenario.html +12 -19
  370. data/rdoc/RubyXL/Scenarios.html +12 -19
  371. data/rdoc/RubyXL/Selection.html +16 -37
  372. data/rdoc/RubyXL/ShapeGuide.html +12 -19
  373. data/rdoc/RubyXL/ShapeTextRectangle.html +12 -19
  374. data/rdoc/RubyXL/SharedStringsTable.html +37 -147
  375. data/rdoc/RubyXL/Sheet.html +12 -19
  376. data/rdoc/RubyXL/SheetCalculationProperties.html +12 -19
  377. data/rdoc/RubyXL/SheetData.html +19 -53
  378. data/rdoc/RubyXL/SheetDataExt.html +12 -19
  379. data/rdoc/RubyXL/SheetDataSet.html +12 -19
  380. data/rdoc/RubyXL/SheetMetadata.html +108 -0
  381. data/rdoc/RubyXL/SheetName.html +12 -19
  382. data/rdoc/RubyXL/SheetNames.html +12 -19
  383. data/rdoc/RubyXL/Sheets.html +12 -19
  384. data/rdoc/RubyXL/SlicerCacheFile.html +11 -25
  385. data/rdoc/RubyXL/SlicerFile.html +11 -25
  386. data/rdoc/RubyXL/SmartTagProperties.html +12 -19
  387. data/rdoc/RubyXL/SmartTagType.html +12 -19
  388. data/rdoc/RubyXL/SmartTagTypes.html +12 -19
  389. data/rdoc/RubyXL/SmartTags.html +12 -19
  390. data/rdoc/RubyXL/SortCondition.html +12 -19
  391. data/rdoc/RubyXL/SortState.html +12 -19
  392. data/rdoc/RubyXL/Sqref.html +19 -53
  393. data/rdoc/RubyXL/Stop.html +12 -19
  394. data/rdoc/RubyXL/StringNode.html +11 -17
  395. data/rdoc/RubyXL/StringNodeW3C.html +20 -54
  396. data/rdoc/RubyXL/StringValue.html +11 -17
  397. data/rdoc/RubyXL/Stylesheet.html +34 -117
  398. data/rdoc/RubyXL/TableFile.html +11 -25
  399. data/rdoc/RubyXL/TableParts.html +11 -17
  400. data/rdoc/RubyXL/TableStyle.html +12 -19
  401. data/rdoc/RubyXL/TableStyles.html +12 -19
  402. data/rdoc/RubyXL/Text.html +22 -67
  403. data/rdoc/RubyXL/TextImportSettings.html +99 -0
  404. data/rdoc/RubyXL/Theme.html +19 -75
  405. data/rdoc/RubyXL/ThemeElements.html +12 -19
  406. data/rdoc/RubyXL/ThumbnailFile.html +11 -25
  407. data/rdoc/RubyXL/Top10.html +12 -19
  408. data/rdoc/RubyXL/VMLDrawingFile.html +14 -32
  409. data/rdoc/RubyXL/Variant.html +12 -19
  410. data/rdoc/RubyXL/Vector.html +17 -38
  411. data/rdoc/RubyXL/VectorValue.html +11 -17
  412. data/rdoc/RubyXL/VisualProperties.html +12 -19
  413. data/rdoc/RubyXL/WebPublishObject.html +12 -19
  414. data/rdoc/RubyXL/WebPublishObjects.html +12 -19
  415. data/rdoc/RubyXL/WebPublishingItem.html +12 -19
  416. data/rdoc/RubyXL/WebPublishingItems.html +12 -19
  417. data/rdoc/RubyXL/WebPublishingProperties.html +12 -19
  418. data/rdoc/RubyXL/WebQueryProperties.html +99 -0
  419. data/rdoc/RubyXL/Workbook.html +486 -227
  420. data/rdoc/RubyXL/WorkbookConvenienceMethods.html +130 -888
  421. data/rdoc/RubyXL/WorkbookProperties.html +12 -19
  422. data/rdoc/RubyXL/WorkbookProtection.html +12 -19
  423. data/rdoc/RubyXL/WorkbookRoot.html +27 -114
  424. data/rdoc/RubyXL/WorkbookView.html +12 -19
  425. data/rdoc/RubyXL/WorkbookViews.html +12 -19
  426. data/rdoc/RubyXL/Worksheet.html +92 -121
  427. data/rdoc/RubyXL/WorksheetConvenienceMethods.html +298 -1109
  428. data/rdoc/RubyXL/WorksheetDimensions.html +12 -19
  429. data/rdoc/RubyXL/WorksheetFormatProperties.html +11 -17
  430. data/rdoc/RubyXL/WorksheetProperties.html +12 -19
  431. data/rdoc/RubyXL/WorksheetProtection.html +12 -19
  432. data/rdoc/RubyXL/WorksheetView.html +12 -19
  433. data/rdoc/RubyXL/WorksheetViews.html +12 -19
  434. data/rdoc/RubyXL/XF.html +12 -19
  435. data/rdoc/RubyXL.html +39 -318
  436. data/rdoc/created.rid +45 -38
  437. data/rdoc/css/rdoc.css +55 -6
  438. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  439. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  440. data/rdoc/index.html +33 -373
  441. data/rdoc/js/darkfish.js +22 -99
  442. data/rdoc/js/navigation.js +4 -41
  443. data/rdoc/js/navigation.js.gz +0 -0
  444. data/rdoc/js/search.js +32 -31
  445. data/rdoc/js/search_index.js +1 -1
  446. data/rdoc/js/search_index.js.gz +0 -0
  447. data/rdoc/js/searcher.js +6 -6
  448. data/rdoc/js/searcher.js.gz +0 -0
  449. data/rdoc/table_of_contents.html +205 -45
  450. data/rubyXL.gemspec +53 -29
  451. data/spec/lib/cell_spec.rb +57 -6
  452. data/spec/lib/color_spec.rb +2 -1
  453. data/spec/lib/parser_spec.rb +24 -27
  454. data/spec/lib/reference_spec.rb +9 -3
  455. data/spec/lib/rgb_color_spec.rb +27 -0
  456. data/spec/lib/stylesheet_spec.rb +8 -11
  457. data/spec/lib/text_spec.rb +1 -5
  458. data/spec/lib/workbook_spec.rb +25 -4
  459. data/spec/lib/worksheet_spec.rb +873 -479
  460. data/spec/spec_helper.rb +2 -0
  461. data/test/test_parse_write.rb +15 -15
  462. metadata +54 -10
  463. data/rdoc/js/jquery.js +0 -4
@@ -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'