rubyXL 3.3.21 → 3.4.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +60 -0
  3. data/.codeclimate.yml +3 -0
  4. data/Gemfile +3 -2
  5. data/Gemfile.lock +96 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.rdoc +47 -16
  8. data/Rakefile +3 -2
  9. data/VERSION +1 -1
  10. data/lib/rubyXL.rb +1 -0
  11. data/lib/rubyXL/cell.rb +1 -26
  12. data/lib/rubyXL/convenience_methods.rb +5 -982
  13. data/lib/rubyXL/convenience_methods/cell.rb +272 -0
  14. data/lib/rubyXL/convenience_methods/color.rb +160 -0
  15. data/lib/rubyXL/convenience_methods/font.rb +63 -0
  16. data/lib/rubyXL/convenience_methods/workbook.rb +136 -0
  17. data/lib/rubyXL/convenience_methods/worksheet.rb +710 -0
  18. data/lib/rubyXL/objects/border.rb +31 -3
  19. data/lib/rubyXL/objects/calculation_chain.rb +2 -2
  20. data/lib/rubyXL/objects/cell_style.rb +8 -8
  21. data/lib/rubyXL/objects/chartsheet.rb +10 -10
  22. data/lib/rubyXL/objects/color.rb +6 -4
  23. data/lib/rubyXL/objects/column_range.rb +10 -10
  24. data/lib/rubyXL/objects/comments.rb +6 -6
  25. data/lib/rubyXL/objects/connection.rb +175 -0
  26. data/lib/rubyXL/objects/container_nodes.rb +2 -2
  27. data/lib/rubyXL/objects/content_types.rb +2 -2
  28. data/lib/rubyXL/objects/data_validation.rb +4 -2
  29. data/lib/rubyXL/objects/document_properties.rb +3 -3
  30. data/lib/rubyXL/objects/extensions.rb +20 -3
  31. data/lib/rubyXL/objects/external_links.rb +26 -2
  32. data/lib/rubyXL/objects/fill.rb +4 -4
  33. data/lib/rubyXL/objects/filters.rb +12 -12
  34. data/lib/rubyXL/objects/font.rb +2 -60
  35. data/lib/rubyXL/objects/formula.rb +1 -1
  36. data/lib/rubyXL/objects/ooxml_object.rb +15 -3
  37. data/lib/rubyXL/objects/query_table.rb +104 -0
  38. data/lib/rubyXL/objects/relationships.rb +8 -3
  39. data/lib/rubyXL/objects/shared_strings.rb +1 -1
  40. data/lib/rubyXL/objects/sheet_common.rb +4 -4
  41. data/lib/rubyXL/objects/sheet_data.rb +48 -11
  42. data/lib/rubyXL/objects/simple_types.rb +18 -0
  43. data/lib/rubyXL/objects/storage.rb +25 -1
  44. data/lib/rubyXL/objects/stylesheet.rb +14 -14
  45. data/lib/rubyXL/objects/text.rb +8 -8
  46. data/lib/rubyXL/objects/theme.rb +138 -119
  47. data/lib/rubyXL/objects/workbook.rb +153 -43
  48. data/lib/rubyXL/objects/worksheet.rb +118 -107
  49. data/lib/rubyXL/worksheet.rb +19 -13
  50. data/rdoc/README_rdoc.html +109 -103
  51. data/rdoc/RubyXL.html +39 -296
  52. data/rdoc/RubyXL/AExtension.html +21 -60
  53. data/rdoc/RubyXL/AExtensionStorageArea.html +12 -17
  54. data/rdoc/RubyXL/ActiveX.html +154 -0
  55. data/rdoc/RubyXL/ActiveXBinary.html +106 -0
  56. data/rdoc/RubyXL/AdjustHandleList.html +13 -19
  57. data/rdoc/RubyXL/Alignment.html +13 -19
  58. data/rdoc/RubyXL/AlternateContent.html +12 -17
  59. data/rdoc/RubyXL/Authors.html +13 -19
  60. data/rdoc/RubyXL/AutoFilter.html +13 -19
  61. data/rdoc/RubyXL/AutoFilterColumn.html +13 -19
  62. data/rdoc/RubyXL/BinaryImageFile.html +12 -25
  63. data/rdoc/RubyXL/BodyProperties.html +13 -19
  64. data/rdoc/RubyXL/BooleanNode.html +12 -17
  65. data/rdoc/RubyXL/BooleanValue.html +12 -17
  66. data/rdoc/RubyXL/Border.html +76 -53
  67. data/rdoc/RubyXL/BorderEdge.html +71 -17
  68. data/rdoc/RubyXL/Borders.html +19 -39
  69. data/rdoc/RubyXL/Break.html +13 -19
  70. data/rdoc/RubyXL/BreakList.html +13 -19
  71. data/rdoc/RubyXL/CT_AdjPoint2D.html +13 -19
  72. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +13 -19
  73. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +13 -19
  74. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +13 -19
  75. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +13 -19
  76. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +13 -19
  77. data/rdoc/RubyXL/CT_Backdrop.html +13 -19
  78. data/rdoc/RubyXL/CT_Bevel.html +13 -19
  79. data/rdoc/RubyXL/CT_BiLevelEffect.html +13 -19
  80. data/rdoc/RubyXL/CT_BlendEffect.html +13 -19
  81. data/rdoc/RubyXL/CT_Blip.html +13 -19
  82. data/rdoc/RubyXL/CT_BlipFillProperties.html +13 -19
  83. data/rdoc/RubyXL/CT_BlurEffect.html +13 -19
  84. data/rdoc/RubyXL/CT_Camera.html +13 -19
  85. data/rdoc/RubyXL/CT_Color.html +13 -19
  86. data/rdoc/RubyXL/CT_ColorChangeEffect.html +13 -19
  87. data/rdoc/RubyXL/CT_ColorMapping.html +13 -19
  88. data/rdoc/RubyXL/CT_ColorScheme.html +13 -19
  89. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +13 -19
  90. data/rdoc/RubyXL/CT_ConnectionSite.html +13 -19
  91. data/rdoc/RubyXL/CT_ConnectionSiteList.html +13 -19
  92. data/rdoc/RubyXL/CT_DashStop.html +13 -19
  93. data/rdoc/RubyXL/CT_DashStopList.html +13 -19
  94. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +13 -19
  95. data/rdoc/RubyXL/CT_DuotoneEffect.html +13 -19
  96. data/rdoc/RubyXL/CT_EffectContainer.html +13 -19
  97. data/rdoc/RubyXL/CT_EffectList.html +13 -19
  98. data/rdoc/RubyXL/CT_EffectReference.html +13 -19
  99. data/rdoc/RubyXL/CT_EffectStyleItem.html +13 -19
  100. data/rdoc/RubyXL/CT_EffectStyleList.html +13 -19
  101. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +13 -19
  102. data/rdoc/RubyXL/CT_FillEffect.html +13 -19
  103. data/rdoc/RubyXL/CT_FillOverlayEffect.html +13 -19
  104. data/rdoc/RubyXL/CT_FillStyleList.html +13 -19
  105. data/rdoc/RubyXL/CT_FlatText.html +13 -19
  106. data/rdoc/RubyXL/CT_FontCollection.html +13 -19
  107. data/rdoc/RubyXL/CT_FontReference.html +13 -19
  108. data/rdoc/RubyXL/CT_GeomGuideList.html +13 -19
  109. data/rdoc/RubyXL/CT_GlowEffect.html +13 -19
  110. data/rdoc/RubyXL/CT_GradientFillProperties.html +13 -19
  111. data/rdoc/RubyXL/CT_GradientStop.html +13 -19
  112. data/rdoc/RubyXL/CT_GradientStopList.html +13 -19
  113. data/rdoc/RubyXL/CT_HSLEffect.html +13 -19
  114. data/rdoc/RubyXL/CT_HslColor.html +13 -19
  115. data/rdoc/RubyXL/CT_Hyperlink.html +13 -19
  116. data/rdoc/RubyXL/CT_InnerShadowEffect.html +13 -19
  117. data/rdoc/RubyXL/CT_LightRig.html +13 -19
  118. data/rdoc/RubyXL/CT_LineEndProperties.html +13 -19
  119. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +13 -19
  120. data/rdoc/RubyXL/CT_LineProperties.html +13 -19
  121. data/rdoc/RubyXL/CT_LineStyleList.html +13 -19
  122. data/rdoc/RubyXL/CT_LinearShadeProperties.html +13 -19
  123. data/rdoc/RubyXL/CT_LuminanceEffect.html +13 -19
  124. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +13 -19
  125. data/rdoc/RubyXL/CT_OuterShadowEffect.html +13 -19
  126. data/rdoc/RubyXL/CT_Path2D.html +13 -19
  127. data/rdoc/RubyXL/CT_Path2DArcTo.html +13 -19
  128. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +13 -19
  129. data/rdoc/RubyXL/CT_Path2DList.html +13 -19
  130. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +13 -19
  131. data/rdoc/RubyXL/CT_Path2DTo.html +13 -19
  132. data/rdoc/RubyXL/CT_PathShadeProperties.html +13 -19
  133. data/rdoc/RubyXL/CT_PatternFillProperties.html +13 -19
  134. data/rdoc/RubyXL/CT_Point3D.html +13 -19
  135. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +13 -19
  136. data/rdoc/RubyXL/CT_PresetColor.html +13 -19
  137. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +13 -19
  138. data/rdoc/RubyXL/CT_PresetShadowEffect.html +13 -19
  139. data/rdoc/RubyXL/CT_PresetTextShape.html +13 -19
  140. data/rdoc/RubyXL/CT_ReflectionEffect.html +13 -19
  141. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +13 -19
  142. data/rdoc/RubyXL/CT_RelativeRect.html +13 -19
  143. data/rdoc/RubyXL/CT_SRgbColor.html +13 -19
  144. data/rdoc/RubyXL/CT_ScRgbColor.html +13 -19
  145. data/rdoc/RubyXL/CT_Scene3D.html +13 -19
  146. data/rdoc/RubyXL/CT_SchemeColor.html +13 -19
  147. data/rdoc/RubyXL/CT_Shape3D.html +13 -19
  148. data/rdoc/RubyXL/CT_ShapeStyle.html +13 -19
  149. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +13 -19
  150. data/rdoc/RubyXL/CT_SphereCoords.html +13 -19
  151. data/rdoc/RubyXL/CT_StretchInfoProperties.html +13 -19
  152. data/rdoc/RubyXL/CT_StyleMatrix.html +13 -19
  153. data/rdoc/RubyXL/CT_StyleMatrixReference.html +13 -19
  154. data/rdoc/RubyXL/CT_SupplementalFont.html +13 -19
  155. data/rdoc/RubyXL/CT_SystemColor.html +13 -19
  156. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +13 -19
  157. data/rdoc/RubyXL/CT_TextBlipBullet.html +13 -19
  158. data/rdoc/RubyXL/CT_TextCharBullet.html +13 -19
  159. data/rdoc/RubyXL/CT_TextCharacterProperties.html +13 -19
  160. data/rdoc/RubyXL/CT_TextFont.html +13 -19
  161. data/rdoc/RubyXL/CT_TextListStyle.html +13 -19
  162. data/rdoc/RubyXL/CT_TextNormalAutofit.html +13 -19
  163. data/rdoc/RubyXL/CT_TextParagraphProperties.html +13 -19
  164. data/rdoc/RubyXL/CT_TextSpacing.html +13 -19
  165. data/rdoc/RubyXL/CT_TextTabStop.html +13 -19
  166. data/rdoc/RubyXL/CT_TextTabStopList.html +13 -19
  167. data/rdoc/RubyXL/CT_TileInfoProperties.html +13 -19
  168. data/rdoc/RubyXL/CT_TintEffect.html +13 -19
  169. data/rdoc/RubyXL/CT_Transform2D.html +13 -19
  170. data/rdoc/RubyXL/CT_TransformEffect.html +13 -19
  171. data/rdoc/RubyXL/CT_Vector3D.html +13 -19
  172. data/rdoc/RubyXL/CT_XYAdjustHandle.html +13 -19
  173. data/rdoc/RubyXL/CalculationChain.html +17 -45
  174. data/rdoc/RubyXL/CalculationChainCell.html +13 -19
  175. data/rdoc/RubyXL/CalculationProperties.html +13 -19
  176. data/rdoc/RubyXL/Cell.html +144 -204
  177. data/rdoc/RubyXL/CellConvenienceMethods.html +240 -426
  178. data/rdoc/RubyXL/CellExt.html +13 -19
  179. data/rdoc/RubyXL/CellSmartTag.html +13 -19
  180. data/rdoc/RubyXL/CellSmartTagProperty.html +13 -19
  181. data/rdoc/RubyXL/CellSmartTags.html +13 -19
  182. data/rdoc/RubyXL/CellStyle.html +13 -19
  183. data/rdoc/RubyXL/CellStyleXFs.html +18 -38
  184. data/rdoc/RubyXL/CellStyles.html +18 -38
  185. data/rdoc/RubyXL/CellValue.html +18 -38
  186. data/rdoc/RubyXL/CellWatch.html +13 -19
  187. data/rdoc/RubyXL/CellWatches.html +13 -19
  188. data/rdoc/RubyXL/CellXFs.html +19 -39
  189. data/rdoc/RubyXL/ChartColorsFile.html +12 -25
  190. data/rdoc/RubyXL/ChartFile.html +19 -49
  191. data/rdoc/RubyXL/ChartStyleFile.html +12 -25
  192. data/rdoc/RubyXL/ChartUserShapesFile.html +12 -25
  193. data/rdoc/RubyXL/Chartsheet.html +19 -67
  194. data/rdoc/RubyXL/ChartsheetPageSetup.html +13 -19
  195. data/rdoc/RubyXL/ChartsheetProperties.html +13 -19
  196. data/rdoc/RubyXL/ChartsheetProtection.html +13 -19
  197. data/rdoc/RubyXL/ChartsheetView.html +13 -19
  198. data/rdoc/RubyXL/ChartsheetViews.html +13 -19
  199. data/rdoc/RubyXL/Color.html +28 -39
  200. data/rdoc/RubyXL/ColorConvenienceClasses.html +91 -0
  201. data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +242 -0
  202. data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +279 -0
  203. data/rdoc/RubyXL/ColorConvenienceMethods.html +137 -0
  204. data/rdoc/RubyXL/ColorFilter.html +13 -19
  205. data/rdoc/RubyXL/ColorScale.html +13 -19
  206. data/rdoc/RubyXL/ColorSet.html +13 -19
  207. data/rdoc/RubyXL/Colors.html +13 -19
  208. data/rdoc/RubyXL/ColumnRange.html +20 -71
  209. data/rdoc/RubyXL/ColumnRanges.html +20 -79
  210. data/rdoc/RubyXL/Comment.html +13 -19
  211. data/rdoc/RubyXL/CommentList.html +13 -19
  212. data/rdoc/RubyXL/CommentsFile.html +17 -50
  213. data/rdoc/RubyXL/ConditionalFormatValue.html +13 -19
  214. data/rdoc/RubyXL/ConditionalFormatting.html +13 -19
  215. data/rdoc/RubyXL/ConditionalFormattingRule.html +13 -19
  216. data/rdoc/RubyXL/Connection.html +99 -0
  217. data/rdoc/RubyXL/ConnectionTable.html +99 -0
  218. data/rdoc/RubyXL/ConnectionTables.html +99 -0
  219. data/rdoc/RubyXL/ConnectionTextField.html +99 -0
  220. data/rdoc/RubyXL/ConnectionTextFields.html +99 -0
  221. data/rdoc/RubyXL/Connections.html +147 -0
  222. data/rdoc/RubyXL/ContentTypeDefault.html +12 -17
  223. data/rdoc/RubyXL/ContentTypeOverride.html +12 -17
  224. data/rdoc/RubyXL/ContentTypes.html +23 -63
  225. data/rdoc/RubyXL/ControlPropertiesFile.html +14 -22
  226. data/rdoc/RubyXL/CorePropertiesFile.html +26 -162
  227. data/rdoc/RubyXL/CustomColor.html +13 -19
  228. data/rdoc/RubyXL/CustomColorList.html +13 -19
  229. data/rdoc/RubyXL/CustomFilter.html +13 -19
  230. data/rdoc/RubyXL/CustomFilters.html +13 -19
  231. data/rdoc/RubyXL/CustomGeometry.html +13 -19
  232. data/rdoc/RubyXL/CustomProperties.html +13 -19
  233. data/rdoc/RubyXL/CustomPropertiesFile.html +12 -25
  234. data/rdoc/RubyXL/CustomProperty.html +13 -19
  235. data/rdoc/RubyXL/CustomPropertyFile.html +108 -0
  236. data/rdoc/RubyXL/CustomSheetView.html +13 -19
  237. data/rdoc/RubyXL/CustomSheetViews.html +13 -19
  238. data/rdoc/RubyXL/CustomWorkbookView.html +13 -19
  239. data/rdoc/RubyXL/CustomWorkbookViews.html +13 -19
  240. data/rdoc/RubyXL/CustomXMLFile.html +12 -22
  241. data/rdoc/RubyXL/DXF.html +13 -19
  242. data/rdoc/RubyXL/DXFs.html +13 -19
  243. data/rdoc/RubyXL/DataBar.html +13 -19
  244. data/rdoc/RubyXL/DataConsolidate.html +13 -19
  245. data/rdoc/RubyXL/DataConsolidationReference.html +13 -19
  246. data/rdoc/RubyXL/DataConsolidationReferences.html +13 -19
  247. data/rdoc/RubyXL/DataType.html +11 -39
  248. data/rdoc/RubyXL/DataValidation.html +13 -19
  249. data/rdoc/RubyXL/DataValidations.html +13 -19
  250. data/rdoc/RubyXL/DateGroupItem.html +13 -19
  251. data/rdoc/RubyXL/DefinedName.html +13 -19
  252. data/rdoc/RubyXL/DefinedNameExt.html +13 -19
  253. data/rdoc/RubyXL/DefinedNames.html +13 -19
  254. data/rdoc/RubyXL/DefinedNamesExt.html +13 -19
  255. data/rdoc/RubyXL/DocumentPropertiesFile.html +20 -66
  256. data/rdoc/RubyXL/DrawingFile.html +19 -49
  257. data/rdoc/RubyXL/DynamicFilter.html +13 -19
  258. data/rdoc/RubyXL/EmbeddedControl.html +13 -19
  259. data/rdoc/RubyXL/EmbeddedControls.html +13 -19
  260. data/rdoc/RubyXL/Extension.html +13 -19
  261. data/rdoc/RubyXL/ExtensionStorageArea.html +13 -19
  262. data/rdoc/RubyXL/Extents.html +13 -19
  263. data/rdoc/RubyXL/ExternalBook.html +13 -19
  264. data/rdoc/RubyXL/ExternalLinksFile.html +19 -49
  265. data/rdoc/RubyXL/ExternalReference.html +13 -19
  266. data/rdoc/RubyXL/ExternalReferences.html +13 -19
  267. data/rdoc/RubyXL/ExtraColorSchemeList.html +13 -19
  268. data/rdoc/RubyXL/FieldItem.html +13 -19
  269. data/rdoc/RubyXL/FileRecoveryProperties.html +13 -19
  270. data/rdoc/RubyXL/FileSharing.html +13 -19
  271. data/rdoc/RubyXL/FileVersion.html +13 -19
  272. data/rdoc/RubyXL/Fill.html +18 -38
  273. data/rdoc/RubyXL/Fills.html +18 -38
  274. data/rdoc/RubyXL/FilterContainer.html +13 -19
  275. data/rdoc/RubyXL/FloatNode.html +12 -17
  276. data/rdoc/RubyXL/FloatValue.html +12 -17
  277. data/rdoc/RubyXL/Font.html +20 -544
  278. data/rdoc/RubyXL/FontConvenienceMethods.html +414 -0
  279. data/rdoc/RubyXL/FontScheme.html +13 -19
  280. data/rdoc/RubyXL/Fonts.html +19 -39
  281. data/rdoc/RubyXL/Formula.html +13 -19
  282. data/rdoc/RubyXL/FunctionGroup.html +13 -19
  283. data/rdoc/RubyXL/FunctionGroups.html +13 -19
  284. data/rdoc/RubyXL/GenericStorageObject.html +19 -81
  285. data/rdoc/RubyXL/GradientFill.html +13 -19
  286. data/rdoc/RubyXL/HeaderFooterSettings.html +13 -19
  287. data/rdoc/RubyXL/Hyperlink.html +13 -19
  288. data/rdoc/RubyXL/HyperlinkRelFile.html +12 -22
  289. data/rdoc/RubyXL/Hyperlinks.html +13 -19
  290. data/rdoc/RubyXL/IconFilter.html +13 -19
  291. data/rdoc/RubyXL/IconSet.html +13 -19
  292. data/rdoc/RubyXL/IgnoredError.html +13 -19
  293. data/rdoc/RubyXL/IgnoredErrors.html +13 -19
  294. data/rdoc/RubyXL/IndexedColors.html +13 -19
  295. data/rdoc/RubyXL/InputCells.html +13 -19
  296. data/rdoc/RubyXL/IntegerNode.html +12 -17
  297. data/rdoc/RubyXL/IntegerValue.html +12 -17
  298. data/rdoc/RubyXL/LegacyCell.html +14 -66
  299. data/rdoc/RubyXL/LegacyWorksheet.html +40 -100
  300. data/rdoc/RubyXL/MRUColors.html +13 -19
  301. data/rdoc/RubyXL/MacrosFile.html +12 -25
  302. data/rdoc/RubyXL/MergedCell.html +13 -19
  303. data/rdoc/RubyXL/MergedCells.html +13 -19
  304. data/rdoc/RubyXL/NumFmt.html +13 -19
  305. data/rdoc/RubyXL/NumberFormat.html +18 -38
  306. data/rdoc/RubyXL/NumberFormats.html +18 -44
  307. data/rdoc/RubyXL/OLEObject.html +13 -19
  308. data/rdoc/RubyXL/OLEObjectFile.html +12 -25
  309. data/rdoc/RubyXL/OLEObjects.html +13 -19
  310. data/rdoc/RubyXL/OLESize.html +13 -19
  311. data/rdoc/RubyXL/OOXMLContainerObject.html +36 -132
  312. data/rdoc/RubyXL/OOXMLIgnored.html +163 -0
  313. data/rdoc/RubyXL/OOXMLObject.html +15 -25
  314. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +88 -179
  315. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +47 -183
  316. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +42 -194
  317. data/rdoc/RubyXL/OOXMLTopLevelObject.html +37 -133
  318. data/rdoc/RubyXL/OdbcOleDbProperties.html +99 -0
  319. data/rdoc/RubyXL/Offset.html +13 -19
  320. data/rdoc/RubyXL/OlapProperties.html +99 -0
  321. data/rdoc/RubyXL/OleItem.html +99 -0
  322. data/rdoc/RubyXL/OleItems.html +99 -0
  323. data/rdoc/RubyXL/OleLink.html +99 -0
  324. data/rdoc/RubyXL/OutlineProperties.html +13 -19
  325. data/rdoc/RubyXL/PageMargins.html +13 -19
  326. data/rdoc/RubyXL/PageSetup.html +13 -19
  327. data/rdoc/RubyXL/PageSetupProperties.html +13 -19
  328. data/rdoc/RubyXL/Pane.html +13 -19
  329. data/rdoc/RubyXL/Parser.html +20 -53
  330. data/rdoc/RubyXL/PatternFill.html +13 -19
  331. data/rdoc/RubyXL/PhoneticProperties.html +13 -19
  332. data/rdoc/RubyXL/PhoneticRun.html +13 -19
  333. data/rdoc/RubyXL/PivotArea.html +13 -19
  334. data/rdoc/RubyXL/PivotCache.html +13 -19
  335. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +14 -30
  336. data/rdoc/RubyXL/PivotCacheRecordsFile.html +12 -25
  337. data/rdoc/RubyXL/PivotCaches.html +13 -19
  338. data/rdoc/RubyXL/PivotReference.html +13 -19
  339. data/rdoc/RubyXL/PivotReferences.html +13 -19
  340. data/rdoc/RubyXL/PivotTableFile.html +14 -30
  341. data/rdoc/RubyXL/PivotTableSelection.html +13 -19
  342. data/rdoc/RubyXL/PresetGeometry.html +13 -19
  343. data/rdoc/RubyXL/PrintOptions.html +13 -19
  344. data/rdoc/RubyXL/PrinterSettingsFile.html +12 -25
  345. data/rdoc/RubyXL/ProtectedRange.html +13 -19
  346. data/rdoc/RubyXL/ProtectedRanges.html +13 -19
  347. data/rdoc/RubyXL/Protection.html +13 -19
  348. data/rdoc/RubyXL/QueryParameter.html +99 -0
  349. data/rdoc/RubyXL/QueryParameters.html +99 -0
  350. data/rdoc/RubyXL/QueryTable.html +155 -0
  351. data/rdoc/RubyXL/QueryTableDeletedField.html +99 -0
  352. data/rdoc/RubyXL/QueryTableDeletedFields.html +99 -0
  353. data/rdoc/RubyXL/QueryTableField.html +99 -0
  354. data/rdoc/RubyXL/QueryTableFields.html +99 -0
  355. data/rdoc/RubyXL/QueryTableRefresh.html +99 -0
  356. data/rdoc/RubyXL/RID.html +12 -17
  357. data/rdoc/RubyXL/RawOOXML.html +19 -58
  358. data/rdoc/RubyXL/Reference.html +31 -215
  359. data/rdoc/RubyXL/Relationship.html +12 -17
  360. data/rdoc/RubyXL/RelationshipSupport.html +32 -126
  361. data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +15 -33
  362. data/rdoc/RubyXL/RevisionPointer.html +99 -0
  363. data/rdoc/RubyXL/RichText.html +18 -38
  364. data/rdoc/RubyXL/RichTextRun.html +17 -37
  365. data/rdoc/RubyXL/Row.html +53 -152
  366. data/rdoc/RubyXL/RowExt.html +13 -19
  367. data/rdoc/RubyXL/RunProperties.html +13 -19
  368. data/rdoc/RubyXL/Scenario.html +13 -19
  369. data/rdoc/RubyXL/Scenarios.html +13 -19
  370. data/rdoc/RubyXL/Selection.html +20 -40
  371. data/rdoc/RubyXL/ShapeGuide.html +13 -19
  372. data/rdoc/RubyXL/ShapeTextRectangle.html +13 -19
  373. data/rdoc/RubyXL/SharedStringsTable.html +31 -140
  374. data/rdoc/RubyXL/Sheet.html +13 -19
  375. data/rdoc/RubyXL/SheetCalculationProperties.html +13 -19
  376. data/rdoc/RubyXL/SheetData.html +20 -53
  377. data/rdoc/RubyXL/SheetDataExt.html +13 -19
  378. data/rdoc/RubyXL/SheetDataSet.html +13 -19
  379. data/rdoc/RubyXL/SheetName.html +13 -19
  380. data/rdoc/RubyXL/SheetNames.html +13 -19
  381. data/rdoc/RubyXL/Sheets.html +13 -19
  382. data/rdoc/RubyXL/SlicerCacheFile.html +12 -25
  383. data/rdoc/RubyXL/SlicerFile.html +12 -25
  384. data/rdoc/RubyXL/SmartTagProperties.html +13 -19
  385. data/rdoc/RubyXL/SmartTagType.html +13 -19
  386. data/rdoc/RubyXL/SmartTagTypes.html +13 -19
  387. data/rdoc/RubyXL/SmartTags.html +13 -19
  388. data/rdoc/RubyXL/SortCondition.html +13 -19
  389. data/rdoc/RubyXL/SortState.html +13 -19
  390. data/rdoc/RubyXL/Sqref.html +18 -51
  391. data/rdoc/RubyXL/Stop.html +13 -19
  392. data/rdoc/RubyXL/StringNode.html +12 -17
  393. data/rdoc/RubyXL/StringNodeW3C.html +19 -52
  394. data/rdoc/RubyXL/StringValue.html +12 -17
  395. data/rdoc/RubyXL/Stylesheet.html +30 -112
  396. data/rdoc/RubyXL/TableFile.html +12 -25
  397. data/rdoc/RubyXL/TableParts.html +12 -17
  398. data/rdoc/RubyXL/TableStyle.html +13 -19
  399. data/rdoc/RubyXL/TableStyles.html +13 -19
  400. data/rdoc/RubyXL/Text.html +19 -63
  401. data/rdoc/RubyXL/TextImportSettings.html +99 -0
  402. data/rdoc/RubyXL/Theme.html +58 -63
  403. data/rdoc/RubyXL/ThemeElements.html +13 -19
  404. data/rdoc/RubyXL/ThumbnailFile.html +12 -25
  405. data/rdoc/RubyXL/Top10.html +13 -19
  406. data/rdoc/RubyXL/VMLDrawingFile.html +15 -32
  407. data/rdoc/RubyXL/Variant.html +13 -19
  408. data/rdoc/RubyXL/Vector.html +17 -37
  409. data/rdoc/RubyXL/VectorValue.html +12 -17
  410. data/rdoc/RubyXL/VisualProperties.html +13 -19
  411. data/rdoc/RubyXL/WebPublishObject.html +13 -19
  412. data/rdoc/RubyXL/WebPublishObjects.html +13 -19
  413. data/rdoc/RubyXL/WebPublishingItem.html +13 -19
  414. data/rdoc/RubyXL/WebPublishingItems.html +13 -19
  415. data/rdoc/RubyXL/WebPublishingProperties.html +13 -19
  416. data/rdoc/RubyXL/WebQueryProperties.html +99 -0
  417. data/rdoc/RubyXL/Workbook.html +483 -226
  418. data/rdoc/RubyXL/WorkbookConvenienceMethods.html +149 -857
  419. data/rdoc/RubyXL/WorkbookProperties.html +13 -19
  420. data/rdoc/RubyXL/WorkbookProtection.html +13 -19
  421. data/rdoc/RubyXL/WorkbookRoot.html +23 -109
  422. data/rdoc/RubyXL/WorkbookView.html +13 -19
  423. data/rdoc/RubyXL/WorkbookViews.html +13 -19
  424. data/rdoc/RubyXL/Worksheet.html +70 -122
  425. data/rdoc/RubyXL/WorksheetConvenienceMethods.html +398 -1049
  426. data/rdoc/RubyXL/WorksheetDimensions.html +13 -19
  427. data/rdoc/RubyXL/WorksheetFormatProperties.html +12 -17
  428. data/rdoc/RubyXL/WorksheetProperties.html +13 -19
  429. data/rdoc/RubyXL/WorksheetProtection.html +13 -19
  430. data/rdoc/RubyXL/WorksheetView.html +13 -19
  431. data/rdoc/RubyXL/WorksheetViews.html +13 -19
  432. data/rdoc/RubyXL/XF.html +13 -19
  433. data/rdoc/created.rid +45 -38
  434. data/rdoc/css/fonts.css +6 -6
  435. data/rdoc/css/rdoc.css +35 -6
  436. data/rdoc/index.html +43 -363
  437. data/rdoc/js/darkfish.js +23 -100
  438. data/rdoc/js/navigation.js +4 -41
  439. data/rdoc/js/navigation.js.gz +0 -0
  440. data/rdoc/js/search.js +32 -31
  441. data/rdoc/js/search_index.js +1 -1
  442. data/rdoc/js/search_index.js.gz +0 -0
  443. data/rdoc/js/searcher.js +7 -6
  444. data/rdoc/js/searcher.js.gz +0 -0
  445. data/rdoc/table_of_contents.html +368 -75
  446. data/rubyXL.gemspec +60 -26
  447. data/spec/lib/cell_spec.rb +147 -2
  448. data/spec/lib/color_spec.rb +1 -0
  449. data/spec/lib/parser_spec.rb +1 -1
  450. data/spec/lib/rgb_color_spec.rb +16 -0
  451. data/spec/lib/text_spec.rb +8 -0
  452. data/spec/lib/workbook_spec.rb +12 -1
  453. data/spec/lib/worksheet_spec.rb +353 -37
  454. data/test/test_parse_write.rb +15 -15
  455. metadata +63 -9
  456. data/rdoc/js/jquery.js +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f94fc6b7b6d611cb2eecd1874bd470d5bade0f3c
4
- data.tar.gz: 98008cf42d8e16856682e9dfcd60c740c1205c2c
2
+ SHA256:
3
+ metadata.gz: 51db2d850a23f726d765f58fdaad378dd910becb0e468216095a1473a5770b9c
4
+ data.tar.gz: 56fbd84fb09a54fe29dcdb6f734c6ade11737d11dbe2130633dccc35999e85cd
5
5
  SHA512:
6
- metadata.gz: 6daeb64ab265ad3f575b2da82fc110f2a5eff40b4f0e85b45135ecdbb220d9524242c1df14da1062b9463fe53cd7129efd342f5c1d5aec69f6cb4f14dd2283d3
7
- data.tar.gz: 50bc7566f9399a1d2b4c74128a56dc36fd4b9f7c941346e3bbb731d96a64bf4634e76b606c17ea81f4c13fa77bf163589dd1dabedfe1cb5610877ad1f07c24cc
6
+ metadata.gz: e8a733f1ba635667d621ae7f02990c0ac4aeac8554b554ed9474c0b28b0e265c2a5e1071be43d6cc968911da58887a78dcedbe6fbae18d79be0fddc9093e1c4c
7
+ data.tar.gz: 4ac723e0a0508a9f6235e57c702c453dfa01a7941a1a27fe072f4a411bd186cfc76de15150f8a4a4cf80779885e7623012f2d9c3ba6fa30e48bedff262f94bbf
@@ -0,0 +1,60 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.6.6-buster
11
+
12
+ # Specify service dependencies here if necessary
13
+ # CircleCI maintains a library of pre-built images
14
+ # documented at https://circleci.com/docs/2.0/circleci-images/
15
+ # - image: circleci/postgres:9.4
16
+
17
+ working_directory: ~/repo
18
+
19
+ steps:
20
+ - checkout
21
+
22
+ # Download and cache dependencies
23
+ - restore_cache:
24
+ keys:
25
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
26
+ # fallback to using the latest cache if no exact match is found
27
+ - v1-dependencies-
28
+
29
+ - run:
30
+ name: install dependencies
31
+ command: |
32
+ gem install bundler
33
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
34
+
35
+ - save_cache:
36
+ paths:
37
+ - ./vendor/bundle
38
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
39
+
40
+ # run tests!
41
+ - run:
42
+ name: run tests
43
+ command: |
44
+ mkdir /tmp/test-results
45
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
46
+ circleci tests split --split-by=timings)"
47
+
48
+ bundle exec rspec \
49
+ --format progress \
50
+ --format RspecJunitFormatter \
51
+ --out /tmp/test-results/rspec.xml \
52
+ --format progress \
53
+ $TEST_FILES
54
+
55
+ # collect reports
56
+ - store_test_results:
57
+ path: /tmp/test-results
58
+ - store_artifacts:
59
+ path: /tmp/test-results
60
+ destination: test-results
data/.codeclimate.yml ADDED
@@ -0,0 +1,3 @@
1
+ exclude_patterns:
2
+ - "rdoc/*"
3
+ - "spec/*"
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  # Dependencies required to run this gem.
4
- gem "nokogiri", ">= 1.4.4"
5
- gem "rubyzip", ">= 1.1.6" , :require => 'zip'
4
+ gem "nokogiri", ">= 1.10.8"
5
+ gem "rubyzip", ">= 1.3.0" , :require => 'zip'
6
6
 
7
7
  # Development dependencies.
8
8
  group :development, :test do
@@ -14,4 +14,5 @@ group :development, :test do
14
14
 
15
15
  # gem 'stackprof'
16
16
  gem 'ruby-prof'
17
+ gem 'rspec_junit_formatter'
17
18
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,96 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.4.0)
5
+ builder (3.2.4)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.4.4)
9
+ docile (1.3.5)
10
+ faraday (0.9.2)
11
+ multipart-post (>= 1.2, < 3)
12
+ git (1.8.1)
13
+ rchardet (~> 1.8)
14
+ github_api (0.16.0)
15
+ addressable (~> 2.4.0)
16
+ descendants_tracker (~> 0.0.4)
17
+ faraday (~> 0.8, < 0.10)
18
+ hashie (>= 3.4)
19
+ mime-types (>= 1.16, < 3.0)
20
+ oauth2 (~> 1.0)
21
+ hashie (4.1.0)
22
+ highline (2.0.3)
23
+ jeweler (2.3.9)
24
+ builder
25
+ bundler
26
+ git (>= 1.2.5)
27
+ github_api (~> 0.16.0)
28
+ highline (>= 1.6.15)
29
+ nokogiri (>= 1.5.10)
30
+ psych
31
+ rake
32
+ rdoc
33
+ semver2
34
+ jwt (2.2.2)
35
+ mime-types (2.99.3)
36
+ mini_portile2 (2.5.0)
37
+ multi_json (1.15.0)
38
+ multi_xml (0.6.0)
39
+ multipart-post (2.1.1)
40
+ nokogiri (1.11.1)
41
+ mini_portile2 (~> 2.5.0)
42
+ racc (~> 1.4)
43
+ oauth2 (1.4.4)
44
+ faraday (>= 0.8, < 2.0)
45
+ jwt (>= 1.0, < 3.0)
46
+ multi_json (~> 1.3)
47
+ multi_xml (~> 0.5)
48
+ rack (>= 1.2, < 3)
49
+ psych (3.3.0)
50
+ racc (1.5.2)
51
+ rack (2.2.3)
52
+ rake (13.0.3)
53
+ rchardet (1.8.0)
54
+ rdoc (6.3.0)
55
+ rspec (3.10.0)
56
+ rspec-core (~> 3.10.0)
57
+ rspec-expectations (~> 3.10.0)
58
+ rspec-mocks (~> 3.10.0)
59
+ rspec-core (3.10.1)
60
+ rspec-support (~> 3.10.0)
61
+ rspec-expectations (3.10.1)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.10.0)
64
+ rspec-mocks (3.10.2)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.10.0)
67
+ rspec-support (3.10.2)
68
+ rspec_junit_formatter (0.4.1)
69
+ rspec-core (>= 2, < 4, != 2.12.0)
70
+ ruby-prof (1.4.2)
71
+ rubyzip (2.3.0)
72
+ semver2 (3.4.2)
73
+ simplecov (0.21.2)
74
+ docile (~> 1.1)
75
+ simplecov-html (~> 0.11)
76
+ simplecov_json_formatter (~> 0.1)
77
+ simplecov-html (0.12.3)
78
+ simplecov_json_formatter (0.1.2)
79
+ thread_safe (0.3.6)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ bundler
86
+ jeweler
87
+ nokogiri (>= 1.10.8)
88
+ rake
89
+ rspec
90
+ rspec_junit_formatter
91
+ ruby-prof
92
+ rubyzip (>= 1.3.0)
93
+ simplecov
94
+
95
+ BUNDLED WITH
96
+ 2.1.4
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Vivek Bhagwat, 2013-2014 Wesha
1
+ Copyright (c) 2011 Vivek Bhagwat, 2013-2020 Wesha
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,13 +1,14 @@
1
1
  = rubyXL
2
2
  {<img src="https://badge.fury.io/rb/rubyXL.svg" alt="Gem Version" />}[http://badge.fury.io/rb/rubyXL]
3
3
  {<img src="https://codeclimate.com/github/weshatheleopard/rubyXL.png" alt="Code Climate" />}[https://codeclimate.com/github/weshatheleopard/rubyXL]
4
+ {<img src="https://circleci.com/gh/weshatheleopard/rubyXL.svg?style=svg" alt="CircleCI" />}[https://circleci.com/gh/weshatheleopard/rubyXL]
4
5
 
5
6
  This gem supports operating on +xlsx+ files (Open XML format). While it is capable
6
7
  of properly parsing the entire OOXML structure, its current main emphasis is on
7
8
  reading files produced by MS Excel, making minor modifications to them and saving
8
9
  them to be opened again, while preserving as much of the structure as possible.
9
10
 
10
- Please note that proprietary binary +xls+ format is *not* supported.
11
+ Please note that proprietary binary +xls+ format is *not* supported by this gem. If you need to parse those files, try {spreadsheet}[https://github.com/zdavatz/spreadsheet] gem.
11
12
 
12
13
  == To Install:
13
14
  gem install rubyXL
@@ -15,6 +16,18 @@ Please note that proprietary binary +xls+ format is *not* supported.
15
16
  == To Use:
16
17
  require 'rubyXL' # Assuming rubygems is already required
17
18
 
19
+ === Convenience methods
20
+
21
+ 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:
22
+ require 'rubyXL/convenience_methods/cell'
23
+ require 'rubyXL/convenience_methods/color'
24
+ require 'rubyXL/convenience_methods/font'
25
+ require 'rubyXL/convenience_methods/workbook'
26
+ require 'rubyXL/convenience_methods/worksheet'
27
+
28
+ 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:
29
+ require 'rubyXL/convenience_methods'
30
+
18
31
  === Parsing an existing workbook
19
32
  workbook = RubyXL::Parser.parse("path/to/Excel/file.xlsx")
20
33
 
@@ -26,7 +39,7 @@ Please note that proprietary binary +xls+ format is *not* supported.
26
39
  ==== Accessing a Worksheet
27
40
  workbook.worksheets[0] # Returns first worksheet
28
41
  workbook[0] # Returns first worksheet
29
- workbook['Sheet1'] # Finds and returns worksheet titled "Sheet1"
42
+ workbook['Sheet1'] # Finds and returns worksheet titled "Sheet1". Note that sheet names in Excel are limited to 31 character.
30
43
 
31
44
  ==== Accessing a Row (Array of Cells)
32
45
  Please note that worksheet is a _sparse_ array of rows. Your code *must* expect that any row it plucks from the array may be <tt>nil</tt>.
@@ -52,6 +65,8 @@ Please note that row is a _sparse_ array of cells. Your code *must* expect that
52
65
  cell.horizontal_alignment
53
66
  cell.vertical_alignment
54
67
  cell.get_border(:top)
68
+ cell.get_border_color(:top)
69
+ cell.text_rotation
55
70
 
56
71
  ==== Wrappers for accessing Row properties
57
72
  Please note: these methods are being phased out in favor of the OOXML object model.
@@ -65,6 +80,7 @@ Please note: these methods are being phased out in favor of the OOXML object mod
65
80
  worksheet.get_row_alignment(0, true)
66
81
  worksheet.get_row_alignment(0, false)
67
82
  worksheet.get_row_border(0, :right)
83
+ worksheet.get_row_border_color(0, :right)
68
84
 
69
85
  ==== Accessing column properties
70
86
  Please note: these methods are being phased out in favor of the OOXML object model.
@@ -78,16 +94,7 @@ Please note: these methods are being phased out in favor of the OOXML object mod
78
94
  worksheet.get_column_alignment(0, :horizontal)
79
95
  worksheet.get_column_alignment(0, :vertical)
80
96
  worksheet.get_column_border(0, :right)
81
-
82
- ==== Table reading
83
- In order to discourage unnecessary reshuffling of data in memory, methods +extract_data+ and +get_table+ are being deprecated. You should access and iterate through rows and cells directly:
84
-
85
- worksheet.each { |row|
86
- row && row.cells.each { |cell|
87
- val = cell && cell.value
88
- do_whatever_you_want(val)
89
- }
90
- }
97
+ worksheet.get_column_border_color(0, :right)
91
98
 
92
99
  === Modifying
93
100
 
@@ -95,7 +102,7 @@ In order to discourage unnecessary reshuffling of data in memory, methods +extra
95
102
  worksheet = workbook.add_worksheet('Sheet2')
96
103
 
97
104
  ==== Renaming Worksheets
98
- worksheet.sheet_name = 'Cool New Name'
105
+ worksheet.sheet_name = 'Cool New Name' # Note that sheet name is limited to 31 characters by Excel.
99
106
 
100
107
  ==== Adding Cells
101
108
  worksheet.add_cell(0, 0, 'A1') # Sets cell A1 to string "A1"
@@ -121,6 +128,10 @@ In order to discourage unnecessary reshuffling of data in memory, methods +extra
121
128
  worksheet.change_row_border(0, :left, 'hairline') # Sets first row to have a left, hairline border
122
129
  worksheet.change_column_border(0, :diagonal, 'medium') # Sets first column to have diagonal, medium border
123
130
 
131
+ # Set the border style first so there's something to color.
132
+ worksheet.change_row_border_color(0, :top, '0ba53d') # Sets first row to have a green top border
133
+ worksheet.change_column_border_color(0, :top, '0ba53d') # Sets first column to have a green top border
134
+
124
135
  ==== Changing Alignment
125
136
  ===== Horizontal
126
137
  center, distributed, justify, left, right
@@ -133,6 +144,15 @@ bottom, center, distributed, top
133
144
  worksheet.sheet_data[0][0].change_vertical_alignment('bottom') # Sets A1 to be bottom aligned
134
145
  worksheet.change_row_vertical_alignment(0, 'distributed') # Sets first row to be distributed vertically
135
146
  worksheet.change_column_vertical_alignment(0, 'top') # Sets first column to be top aligned
147
+
148
+ ===== Rotation
149
+ worksheet.sheet_data[0][0].change_text_rotation(90) # Sets A1 to be rotated by 90 degrees
150
+
151
+ Values:
152
+ * 0-90 - degrees counterclockwise, around the bottom LEFT corner of the cell;
153
+ * 91-179 - degrees clockwise, around the bottom RIGHT corner of the cell;
154
+ * 180-254 - degrees clockwise, around the bottom LEFT corner of the cell, text becomes progressively invisible
155
+ * 255 - text is in normal rotation but displayed vertically (one letter under another), line feed starts new line to the right of the previous.
136
156
 
137
157
  ==== Changing Row Height
138
158
  worksheet.change_row_height(0, 30) # Sets first row height to 30
@@ -186,6 +206,8 @@ WARNING: Use of this method WILL break formulas referencing cells which have bee
186
206
  ==== Modifying Cell Format
187
207
  cell = worksheet[0][0]
188
208
  cell.set_number_format '0.0000%' # For formats, see https://support.office.com/en-us/article/5026bbd6-04bc-48cd-bf33-80f18b4eae68
209
+ cell.change_text_wrap(true) # Makes the text in the cell to wrap.
210
+ cell.change_text_indent(1) # Indents the text in the cell by 1 level
189
211
 
190
212
  == I/O
191
213
 
@@ -200,8 +222,17 @@ It can also operate on +StringIO+ objects, thus eliminating the need to save the
200
222
  workbook.stream
201
223
 
202
224
  == Miscellaneous
203
- Reference.ind2ref(0,0) == 'A1' # Converts row and column index to Excel-style cell reference
204
- Reference.ref2ind('A1') == [0, 0] # Converts Excel-style cell reference to row and column index
225
+ RubyXL::Reference.ind2ref(0,0) == 'A1' # Converts row and column index to Excel-style cell reference
226
+ RubyXL::Reference.ref2ind('A1') == [0, 0] # Converts Excel-style cell reference to row and column index
227
+
228
+ === Suppress warnings about malformed input files
229
+
230
+ RubyXL.class_variable_set(:@@suppress_warnings, true)
231
+
232
+ == Data validation ("dropdown list")
233
+
234
+ worksheet.add_validation_list("A1", [ "value1", "value2" ])
235
+
205
236
 
206
237
  == For more information
207
238
  Take a look at the files in spec/lib/ for rspecs on most methods
@@ -218,5 +249,5 @@ Take a look at the files in spec/lib/ for rspecs on most methods
218
249
 
219
250
  == Copyright
220
251
 
221
- Copyright (c) 2011 Vivek Bhagwat, 2013-2016 Wesha.
252
+ Copyright (c) 2011 Vivek Bhagwat, 2013-2020 Wesha.
222
253
  See LICENSE.txt for further details.
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.description = %Q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
21
21
  gem.email = "bhagwat.vivek@gmail.com"
22
22
  gem.authors = ["Vivek Bhagwat", 'Wesha']
23
+ # gem.required_ruby_version = '>2.1'
23
24
  # dependencies defined in Gemfile
24
25
  end
25
26
  Jeweler::RubygemsDotOrgTasks.new
@@ -33,8 +34,8 @@ Rake::TestTask.new(:test) do |test|
33
34
  end
34
35
 
35
36
  require 'rspec/core/rake_task'
36
- RSpec::Core::RakeTask.new(:spec)
37
- task :default => :spec
37
+ RSpec::Core::RakeTask.new(:rspec)
38
+ task :default => :rspec
38
39
 
39
40
  require 'rdoc/task'
40
41
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.21
1
+ 3.4.17
data/lib/rubyXL.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubyXL/objects/root'
2
2
  require 'rubyXL/parser'
3
3
 
4
4
  module RubyXL
5
+ @@suppress_warnings = false
5
6
 
6
7
  # Convert any path passed to absolute path (within the XLSX file).
7
8
  def self.from_root(path)
data/lib/rubyXL/cell.rb CHANGED
@@ -1,19 +1,6 @@
1
1
  module RubyXL
2
2
 
3
- # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.cellvalues(v=office.14).aspx
4
- module DataType
5
- SHARED_STRING = 's'
6
- RAW_STRING = 'str'
7
- INLINE_STRING = 'inlineStr'
8
- ERROR = 'e'
9
- BOOLEAN = 'b'
10
- NUMBER = 'n'
11
- DATE = 'd' # Only available in Office2010.
12
- end
13
-
14
3
  module LegacyCell
15
- attr_accessor :formula, :worksheet
16
-
17
4
  def workbook
18
5
  @worksheet.workbook
19
6
  end
@@ -34,21 +21,9 @@ module RubyXL
34
21
  end
35
22
 
36
23
  def validate_worksheet()
37
- return if @worksheet && @worksheet[row] && @worksheet[row][column] == self
24
+ return if @worksheet && @worksheet[row] && @worksheet[row][column].equal?(self)
38
25
  raise "Cell #{self} is not in worksheet #{worksheet}"
39
26
  end
40
27
 
41
- def get_cell_xf
42
- workbook.cell_xfs[self.style_index || 0]
43
- end
44
-
45
- def get_cell_font
46
- workbook.fonts[get_cell_xf.font_id]
47
- end
48
-
49
- def get_cell_border
50
- workbook.borders[get_cell_xf.border_id]
51
- end
52
-
53
28
  end
54
29
  end
@@ -1,982 +1,5 @@
1
- module RubyXL
2
-
3
- module WorkbookConvenienceMethods
4
- SHEET_NAME_TEMPLATE = 'Sheet%d'
5
-
6
- # Finds worksheet by its name or numerical index
7
- def [](ind)
8
- case ind
9
- when Integer then worksheets[ind]
10
- when String then worksheets.find { |ws| ws.sheet_name == ind }
11
- end
12
- end
13
-
14
- # Create new simple worksheet and add it to the workbook worksheets
15
- #
16
- # @param [String] The name for the new worksheet
17
- def add_worksheet(name = nil)
18
- if name.nil? then
19
- n = 0
20
-
21
- begin
22
- name = SHEET_NAME_TEMPLATE % (n += 1)
23
- end until self[name].nil?
24
- end
25
-
26
- new_worksheet = Worksheet.new(:workbook => self, :sheet_name => name)
27
- worksheets << new_worksheet
28
- new_worksheet
29
- end
30
-
31
- def each
32
- worksheets.each{ |i| yield i }
33
- end
34
-
35
- def date1904
36
- workbook_properties && workbook_properties.date1904
37
- end
38
-
39
- def date1904=(v)
40
- self.workbook_properties ||= RubyXL::WorkbookProperties.new
41
- workbook_properties.date1904 = v
42
- end
43
-
44
- def company
45
- root.document_properties.company && root.document_properties.company.value
46
- end
47
-
48
- def company=(v)
49
- root.document_properties.company ||= StringNode.new
50
- root.document_properties.company.value = v
51
- end
52
-
53
- def application
54
- root.document_properties.application && root.document_properties.application.value
55
- end
56
-
57
- def application=(v)
58
- root.document_properties.application ||= StringNode.new
59
- root.document_properties.application.value = v
60
- end
61
-
62
- def appversion
63
- root.document_properties.app_version && root.document_properties.app_version.value
64
- end
65
-
66
- def appversion=(v)
67
- root.document_properties.app_version ||= StringNode.new
68
- root.document_properties.app_version.value = v
69
- end
70
-
71
- def creator
72
- root.core_properties.creator
73
- end
74
-
75
- def creator=(v)
76
- root.core_properties.creator = v
77
- end
78
-
79
- def modifier
80
- root.core_properties.modifier
81
- end
82
-
83
- def modifier=(v)
84
- root.core_properties.modifier = v
85
- end
86
-
87
- def created_at
88
- root.core_properties.created_at
89
- end
90
-
91
- def created_at=(v)
92
- root.core_properties.created_at = v
93
- end
94
-
95
- def modified_at
96
- root.core_properties.modified_at
97
- end
98
-
99
- def modified_at=(v)
100
- root.core_properties.modified_at = v
101
- end
102
-
103
- def cell_xfs # Stylesheet should be pre-filled with defaults on initialize()
104
- stylesheet.cell_xfs
105
- end
106
-
107
- def fonts # Stylesheet should be pre-filled with defaults on initialize()
108
- stylesheet.fonts
109
- end
110
-
111
- def fills # Stylesheet should be pre-filled with defaults on initialize()
112
- stylesheet.fills
113
- end
114
-
115
- def borders # Stylesheet should be pre-filled with defaults on initialize()
116
- stylesheet.borders
117
- end
118
-
119
- def get_fill_color(xf)
120
- fill = fills[xf.fill_id]
121
- pattern = fill && fill.pattern_fill
122
- color = pattern && pattern.fg_color
123
- color && color.rgb || 'ffffff'
124
- end
125
-
126
- def register_new_fill(new_fill, old_xf)
127
- new_xf = old_xf.dup
128
- new_xf.apply_fill = true
129
- new_xf.fill_id = fills.find_index { |x| x == new_fill } # Reuse existing fill, if it exists
130
- new_xf.fill_id ||= fills.size # If this fill has never existed before, add it to collection.
131
- fills[new_xf.fill_id] = new_fill
132
- new_xf
133
- end
134
-
135
- def register_new_font(new_font, old_xf)
136
- new_xf = old_xf.dup
137
- new_xf.font_id = fonts.find_index { |x| x == new_font } # Reuse existing font, if it exists
138
- new_xf.font_id ||= fonts.size # If this font has never existed before, add it to collection.
139
- fonts[new_xf.font_id] = new_font
140
- new_xf.apply_font = true
141
- new_xf
142
- end
143
-
144
- def register_new_xf(new_xf)
145
- new_xf_id = cell_xfs.find_index { |xf| xf == new_xf } # Reuse existing XF, if it exists
146
- new_xf_id ||= cell_xfs.size # If this XF has never existed before, add it to collection.
147
- cell_xfs[new_xf_id] = new_xf
148
- new_xf_id
149
- end
150
-
151
- def modify_alignment(style_index, &block)
152
- xf = cell_xfs[style_index || 0].dup
153
- xf.alignment ||= RubyXL::Alignment.new
154
- yield(xf.alignment)
155
- xf.apply_alignment = true
156
-
157
- register_new_xf(xf)
158
- end
159
-
160
- def modify_fill(style_index, rgb)
161
- xf = cell_xfs[style_index || 0].dup
162
- new_fill = RubyXL::Fill.new(:pattern_fill =>
163
- RubyXL::PatternFill.new(:pattern_type => 'solid',
164
- :fg_color => RubyXL::Color.new(:rgb => rgb)))
165
- register_new_xf(register_new_fill(new_fill, xf))
166
- end
167
-
168
- def modify_border(style_index, direction, weight)
169
- xf = cell_xfs[style_index || 0].dup
170
- new_border = borders[xf.border_id || 0].dup
171
- new_border.set_edge_style(direction, weight)
172
-
173
- xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
174
- xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
175
- borders[xf.border_id] = new_border
176
- xf.apply_border = true
177
-
178
- register_new_xf(xf)
179
- end
180
-
181
- end
182
-
183
-
184
- module WorksheetConvenienceMethods
185
- NAME = 0
186
- SIZE = 1
187
- COLOR = 2
188
- ITALICS = 3
189
- BOLD = 4
190
- UNDERLINE = 5
191
- STRIKETHROUGH = 6
192
-
193
- def insert_cell(row = 0, col = 0, data = nil, formula = nil, shift = nil)
194
- validate_workbook
195
- ensure_cell_exists(row, col)
196
-
197
- case shift
198
- when nil then # No shifting at all
199
- when :right then
200
- sheet_data.rows[row].insert_cell_shift_right(nil, col)
201
- when :down then
202
- add_row(sheet_data.size, :cells => Array.new(sheet_data.rows[row].size))
203
- (sheet_data.size - 1).downto(row+1) { |index|
204
- sheet_data.rows[index].cells[col] = sheet_data.rows[index-1].cells[col]
205
- }
206
- else
207
- raise 'invalid shift option'
208
- end
209
-
210
- return add_cell(row, col, data, formula)
211
- end
212
-
213
- # by default, only sets cell to nil
214
- # if :left is specified, method will shift row contents to the right of the deleted cell to the left
215
- # if :up is specified, method will shift column contents below the deleted cell upward
216
- def delete_cell(row_index = 0, column_index=0, shift=nil)
217
- validate_workbook
218
- validate_nonnegative(row_index)
219
- validate_nonnegative(column_index)
220
-
221
- row = sheet_data[row_index]
222
- old_cell = row && row[column_index]
223
-
224
- case shift
225
- when nil then
226
- row.cells[column_index] = nil if row
227
- when :left then
228
- row.delete_cell_shift_left(column_index) if row
229
- when :up then
230
- (row_index...(sheet_data.size - 1)).each { |index|
231
- c = sheet_data.rows[index].cells[column_index] = sheet_data.rows[index + 1].cells[column_index]
232
- c.row -= 1 if c.is_a?(Cell)
233
- }
234
- else
235
- raise 'invalid shift option'
236
- end
237
-
238
- return old_cell
239
- end
240
-
241
- # Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!)
242
- # NOTE: use of this method will break formulas which reference cells which are being "pushed down"
243
- def insert_row(row_index = 0)
244
- validate_workbook
245
- ensure_cell_exists(row_index)
246
-
247
- old_row = new_cells = nil
248
-
249
- if row_index > 0 then
250
- old_row = sheet_data.rows[row_index - 1]
251
- if old_row then
252
- new_cells = old_row.cells.collect { |c|
253
- if c.nil? then nil
254
- else nc = RubyXL::Cell.new(:style_index => c.style_index)
255
- nc.worksheet = self
256
- nc
257
- end
258
- }
259
- end
260
- end
261
-
262
- row0 = sheet_data.rows[0]
263
- new_cells ||= Array.new((row0 && row0.cells.size) || 0)
264
-
265
- sheet_data.rows.insert(row_index, nil)
266
- new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
267
-
268
- # Update row values for all rows below
269
- row_index.upto(sheet_data.rows.size - 1) { |r|
270
- row = sheet_data.rows[r]
271
- next if row.nil?
272
- row.cells.each_with_index { |cell, c|
273
- next if cell.nil?
274
- cell.r = RubyXL::Reference.new(r, c)
275
- }
276
- }
277
-
278
- return new_row
279
- end
280
-
281
- def delete_row(row_index=0)
282
- validate_workbook
283
- validate_nonnegative(row_index)
284
-
285
- deleted = sheet_data.rows.delete_at(row_index)
286
-
287
- # Update row number of each cell
288
- row_index.upto(sheet_data.size - 1) { |index|
289
- row = sheet_data[index]
290
- row && row.cells.each{ |c| c.row -= 1 unless c.nil? }
291
- }
292
-
293
- return deleted
294
- end
295
-
296
- # Inserts column at +column_index+, pushes everything right, takes styles from column to left
297
- # NOTE: use of this method will break formulas which reference cells which are being "pushed right"
298
- def insert_column(column_index = 0)
299
- validate_workbook
300
- ensure_cell_exists(0, column_index)
301
-
302
- old_range = cols.get_range(column_index)
303
-
304
- #go through each cell in column
305
- sheet_data.rows.each_with_index { |row, row_index|
306
- old_cell = row[column_index]
307
- c = nil
308
-
309
- if old_cell && old_cell.style_index != 0 &&
310
- old_range && old_range.style_index != old_cell.style_index then
311
-
312
- c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
313
- :row => row_index, :column => column_index,
314
- :datatype => RubyXL::DataType::SHARED_STRING)
315
- end
316
-
317
- row.insert_cell_shift_right(c, column_index)
318
- }
319
-
320
- cols.insert_column(column_index)
321
-
322
- # TODO: update column numbers
323
- end
324
-
325
- def delete_column(column_index = 0)
326
- validate_workbook
327
- validate_nonnegative(column_index)
328
-
329
- # Delete column
330
- sheet_data.rows.each { |row| row.cells.delete_at(column_index) }
331
-
332
- # Update column numbers for cells to the right of the deleted column
333
- sheet_data.rows.each_with_index { |row, row_index|
334
- row.cells.each_with_index { |c, ci|
335
- c.column = ci if c.is_a?(Cell)
336
- }
337
- }
338
-
339
- cols.each { |range| range.delete_column(column_index) }
340
- end
341
-
342
- def get_row_style(row_index)
343
- row = sheet_data.rows[row_index]
344
- (row && row.style_index) || 0
345
- end
346
-
347
- def get_row_fill(row = 0)
348
- (row = sheet_data.rows[row]) && row.get_fill_color
349
- end
350
-
351
- def get_row_font_name(row = 0)
352
- (font = row_font(row)) && font.get_name
353
- end
354
-
355
- def get_row_font_size(row = 0)
356
- (font = row_font(row)) && font.get_size
357
- end
358
-
359
- def get_row_font_color(row = 0)
360
- font = row_font(row)
361
- color = font && font.color
362
- color && (color.rgb || '000000')
363
- end
364
-
365
- def is_row_italicized(row = 0)
366
- (font = row_font(row)) && font.is_italic
367
- end
368
-
369
- def is_row_bolded(row = 0)
370
- (font = row_font(row)) && font.is_bold
371
- end
372
-
373
- def is_row_underlined(row = 0)
374
- (font = row_font(row)) && font.is_underlined
375
- end
376
-
377
- def is_row_struckthrough(row = 0)
378
- (font = row_font(row)) && font.is_strikethrough
379
- end
380
-
381
- def get_row_height(row = 0)
382
- validate_workbook
383
- validate_nonnegative(row)
384
- row = sheet_data.rows[row]
385
- row && row.ht || RubyXL::Row::DEFAULT_HEIGHT
386
- end
387
-
388
- def get_row_border(row, border_direction)
389
- validate_workbook
390
-
391
- border = @workbook.borders[get_row_xf(row).border_id]
392
- border && border.get_edge_style(border_direction)
393
- end
394
-
395
- def row_font(row)
396
- (row = sheet_data.rows[row]) && row.get_font
397
- end
398
-
399
- def get_row_alignment(row, is_horizontal)
400
- validate_workbook
401
-
402
- xf_obj = get_row_xf(row)
403
- return nil if xf_obj.alignment.nil?
404
-
405
- if is_horizontal then return xf_obj.alignment.horizontal
406
- else return xf_obj.alignment.vertical
407
- end
408
- end
409
-
410
- def get_cols_style_index(column_index)
411
- validate_nonnegative(column_index)
412
- range = cols.locate_range(column_index)
413
- (range && range.style_index) || 0
414
- end
415
-
416
- def get_column_font_name(col = 0)
417
- font = column_font(col)
418
- font && font.get_name
419
- end
420
-
421
- def get_column_font_size(col = 0)
422
- font = column_font(col)
423
- font && font.get_size
424
- end
425
-
426
- def get_column_font_color(col = 0)
427
- font = column_font(col)
428
- font && (font.get_rgb_color || '000000')
429
- end
430
-
431
- def is_column_italicized(col = 0)
432
- font = column_font(col)
433
- font && font.is_italic
434
- end
435
-
436
- def is_column_bolded(col = 0)
437
- font = column_font(col)
438
- font && font.is_bold
439
- end
440
-
441
- def is_column_underlined(col = 0)
442
- font = column_font(col)
443
- font && font.is_underlined
444
- end
445
-
446
- def is_column_struckthrough(col = 0)
447
- font = column_font(col)
448
- font && font.is_strikethrough
449
- end
450
-
451
- # Get raw column width value as stored in the file
452
- def get_column_width_raw(column_index = 0)
453
- validate_workbook
454
- validate_nonnegative(column_index)
455
-
456
- range = cols.locate_range(column_index)
457
- range && range.width
458
- end
459
-
460
- # Get column width measured in number of digits, as per
461
- # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
462
- def get_column_width(column_index = 0)
463
- width = get_column_width_raw(column_index)
464
- return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
465
- (width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
466
- end
467
-
468
- # Set raw column width value
469
- def change_column_width_raw(column_index, width)
470
- validate_workbook
471
- ensure_cell_exists(0, column_index)
472
- range = cols.get_range(column_index)
473
- range.width = width
474
- range.custom_width = true
475
- end
476
-
477
- # Get column width measured in number of digits, as per
478
- # http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
479
- def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
480
- change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
481
- end
482
-
483
- # Helper method to get the style index for a column
484
- def get_col_style(column_index)
485
- range = cols.locate_range(column_index)
486
- (range && range.style_index) || 0
487
- end
488
-
489
- def get_column_fill(col=0)
490
- validate_workbook
491
- validate_nonnegative(col)
492
-
493
- @workbook.get_fill_color(get_col_xf(col))
494
- end
495
-
496
- def change_column_fill(column_index, color_code = 'ffffff')
497
- validate_workbook
498
- RubyXL::Color.validate_color(color_code)
499
- ensure_cell_exists(0, column_index)
500
-
501
- cols.get_range(column_index).style_index = @workbook.modify_fill(get_col_style(column_index), color_code)
502
-
503
- sheet_data.rows.each { |row|
504
- c = row[column_index]
505
- c.change_fill(color_code) if c
506
- }
507
- end
508
-
509
- def get_column_border(col, border_direction)
510
- validate_workbook
511
-
512
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
513
- border = @workbook.borders[xf.border_id]
514
- border && border.get_edge_style(border_direction)
515
- end
516
-
517
- def column_font(col)
518
- validate_workbook
519
-
520
- @workbook.fonts[@workbook.cell_xfs[get_cols_style_index(col)].font_id]
521
- end
522
-
523
- def get_column_alignment(col, type)
524
- validate_workbook
525
-
526
- xf = @workbook.cell_xfs[get_cols_style_index(col)]
527
- xf.alignment && xf.alignment.send(type)
528
- end
529
-
530
- def change_row_horizontal_alignment(row = 0, alignment = 'center')
531
- validate_workbook
532
- validate_nonnegative(row)
533
- change_row_alignment(row) { |a| a.horizontal = alignment }
534
- end
535
-
536
- def change_row_vertical_alignment(row = 0, alignment = 'center')
537
- validate_workbook
538
- validate_nonnegative(row)
539
- change_row_alignment(row) { |a| a.vertical = alignment }
540
- end
541
-
542
- def change_row_border(row, direction, weight)
543
- validate_workbook
544
- ensure_cell_exists(row)
545
-
546
- sheet_data.rows[row].style_index = @workbook.modify_border(get_row_style(row), direction, weight)
547
-
548
- sheet_data[row].cells.each { |c|
549
- c.change_border(direction, weight) unless c.nil?
550
- }
551
- end
552
-
553
- def change_row_fill(row_index = 0, rgb = 'ffffff')
554
- validate_workbook
555
- ensure_cell_exists(row_index)
556
- Color.validate_color(rgb)
557
-
558
- sheet_data.rows[row_index].style_index = @workbook.modify_fill(get_row_style(row_index), rgb)
559
- sheet_data[row_index].cells.each { |c| c.change_fill(rgb) unless c.nil? }
560
- end
561
-
562
- # Helper method to update the row styles array
563
- # change_type - NAME or SIZE or COLOR etc
564
- # main method to change font, called from each separate font mutator method
565
- def change_row_font(row_index, change_type, arg, font)
566
- validate_workbook
567
- ensure_cell_exists(row_index)
568
-
569
- xf = workbook.register_new_font(font, get_row_xf(row_index))
570
- row = sheet_data[row_index]
571
- row.style_index = workbook.register_new_xf(xf)
572
- row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
573
- end
574
-
575
- def change_row_font_name(row = 0, font_name = 'Verdana')
576
- ensure_cell_exists(row)
577
- font = row_font(row).dup
578
- font.set_name(font_name)
579
- change_row_font(row, Worksheet::NAME, font_name, font)
580
- end
581
-
582
- def change_row_font_size(row = 0, font_size=10)
583
- ensure_cell_exists(row)
584
- font = row_font(row).dup
585
- font.set_size(font_size)
586
- change_row_font(row, Worksheet::SIZE, font_size, font)
587
- end
588
-
589
- def change_row_font_color(row = 0, font_color = '000000')
590
- ensure_cell_exists(row)
591
- Color.validate_color(font_color)
592
- font = row_font(row).dup
593
- font.set_rgb_color(font_color)
594
- change_row_font(row, Worksheet::COLOR, font_color, font)
595
- end
596
-
597
- def change_row_italics(row = 0, italicized = false)
598
- ensure_cell_exists(row)
599
- font = row_font(row).dup
600
- font.set_italic(italicized)
601
- change_row_font(row, Worksheet::ITALICS, italicized, font)
602
- end
603
-
604
- def change_row_bold(row = 0, bolded = false)
605
- ensure_cell_exists(row)
606
- font = row_font(row).dup
607
- font.set_bold(bolded)
608
- change_row_font(row, Worksheet::BOLD, bolded, font)
609
- end
610
-
611
- def change_row_underline(row = 0, underlined=false)
612
- ensure_cell_exists(row)
613
- font = row_font(row).dup
614
- font.set_underline(underlined)
615
- change_row_font(row, Worksheet::UNDERLINE, underlined, font)
616
- end
617
-
618
- def change_row_strikethrough(row = 0, struckthrough=false)
619
- ensure_cell_exists(row)
620
- font = row_font(row).dup
621
- font.set_strikethrough(struckthrough)
622
- change_row_font(row, Worksheet::STRIKETHROUGH, struckthrough, font)
623
- end
624
-
625
- def change_row_height(row = 0, height = 10)
626
- validate_workbook
627
- ensure_cell_exists(row)
628
-
629
- c = sheet_data.rows[row]
630
- c.ht = height
631
- c.custom_height = true
632
- end
633
-
634
- # Helper method to update the fonts and cell styles array
635
- # main method to change font, called from each separate font mutator method
636
- def change_column_font(column_index, change_type, arg, font, xf)
637
- validate_workbook
638
- ensure_cell_exists(0, column_index)
639
-
640
- xf = workbook.register_new_font(font, xf)
641
- cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
642
-
643
- sheet_data.rows.each { |row|
644
- c = row && row[column_index]
645
- c.font_switch(change_type, arg) unless c.nil?
646
- }
647
- end
648
-
649
- def change_column_font_name(column_index = 0, font_name = 'Verdana')
650
- xf = get_col_xf(column_index)
651
- font = @workbook.fonts[xf.font_id].dup
652
- font.set_name(font_name)
653
- change_column_font(column_index, Worksheet::NAME, font_name, font, xf)
654
- end
655
-
656
- def change_column_font_size(column_index, font_size=10)
657
- xf = get_col_xf(column_index)
658
- font = @workbook.fonts[xf.font_id].dup
659
- font.set_size(font_size)
660
- change_column_font(column_index, Worksheet::SIZE, font_size, font, xf)
661
- end
662
-
663
- def change_column_font_color(column_index, font_color='000000')
664
- Color.validate_color(font_color)
665
-
666
- xf = get_col_xf(column_index)
667
- font = @workbook.fonts[xf.font_id].dup
668
- font.set_rgb_color(font_color)
669
- change_column_font(column_index, Worksheet::COLOR, font_color, font, xf)
670
- end
671
-
672
- def change_column_italics(column_index, italicized = false)
673
- xf = get_col_xf(column_index)
674
- font = @workbook.fonts[xf.font_id].dup
675
- font.set_italic(italicized)
676
- change_column_font(column_index, Worksheet::ITALICS, italicized, font, xf)
677
- end
678
-
679
- def change_column_bold(column_index, bolded = false)
680
- xf = get_col_xf(column_index)
681
- font = @workbook.fonts[xf.font_id].dup
682
- font.set_bold(bolded)
683
- change_column_font(column_index, Worksheet::BOLD, bolded, font, xf)
684
- end
685
-
686
- def change_column_underline(column_index, underlined = false)
687
- xf = get_col_xf(column_index)
688
- font = @workbook.fonts[xf.font_id].dup
689
- font.set_underline(underlined)
690
- change_column_font(column_index, Worksheet::UNDERLINE, underlined, font, xf)
691
- end
692
-
693
- def change_column_strikethrough(column_index, struckthrough=false)
694
- xf = get_col_xf(column_index)
695
- font = @workbook.fonts[xf.font_id].dup
696
- font.set_strikethrough(struckthrough)
697
- change_column_font(column_index, Worksheet::STRIKETHROUGH, struckthrough, font, xf)
698
- end
699
-
700
- def change_column_horizontal_alignment(column_index, alignment = 'center')
701
- change_column_alignment(column_index) { |a| a.horizontal = alignment }
702
- end
703
-
704
- def change_column_vertical_alignment(column_index, alignment = 'center')
705
- change_column_alignment(column_index) { |a| a.vertical = alignment }
706
- end
707
-
708
- def change_column_border(column_index, direction, weight)
709
- validate_workbook
710
- ensure_cell_exists(0, column_index)
711
-
712
- cols.get_range(column_index).style_index = @workbook.modify_border(get_col_style(column_index), direction, weight)
713
-
714
- sheet_data.rows.each { |row|
715
- c = row.cells[column_index]
716
- c.change_border(direction, weight) unless c.nil?
717
- }
718
- end
719
-
720
- def change_row_alignment(row, &block)
721
- validate_workbook
722
- validate_nonnegative(row)
723
- ensure_cell_exists(row)
724
-
725
- sheet_data.rows[row].style_index = @workbook.modify_alignment(get_row_style(row), &block)
726
-
727
- sheet_data[row].cells.each { |c|
728
- next if c.nil?
729
- c.style_index = @workbook.modify_alignment(c.style_index, &block)
730
- }
731
- end
732
-
733
- def change_column_alignment(column_index, &block)
734
- validate_workbook
735
- ensure_cell_exists(0, column_index)
736
-
737
- cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
738
- # Excel gets confused if width is not explicitly set for a column that had alignment changes
739
- change_column_width(column_index) if get_column_width_raw(column_index).nil?
740
-
741
- sheet_data.rows.each { |row|
742
- c = row[column_index]
743
- next if c.nil?
744
- c.style_index = @workbook.modify_alignment(c.style_index, &block)
745
- }
746
- end
747
-
748
- # Merges cells within a rectangular area
749
- def merge_cells(start_row, start_col, end_row, end_col)
750
- validate_workbook
751
-
752
- self.merged_cells ||= RubyXL::MergedCells.new
753
- # TODO: add validation to make sure ranges are not intersecting with existing ones
754
- merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
755
- end
756
- end
757
-
758
- module CellConvenienceMethods
759
-
760
- def change_contents(data, formula_expression = nil)
761
- validate_worksheet
762
-
763
- if formula_expression then
764
- self.datatype = nil
765
- self.formula = RubyXL::Formula.new(:expression => formula_expression)
766
- else
767
- self.datatype = case data
768
- when Date, Numeric then nil
769
- else RubyXL::DataType::RAW_STRING
770
- end
771
- end
772
-
773
- data = workbook.date_to_num(data) if data.is_a?(Date)
774
-
775
- self.raw_value = data
776
- end
777
-
778
- def get_border(direction)
779
- validate_worksheet
780
- get_cell_border.get_edge_style(direction)
781
- end
782
-
783
- def change_horizontal_alignment(alignment = 'center')
784
- validate_worksheet
785
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.horizontal = alignment }
786
- end
787
-
788
- def change_vertical_alignment(alignment = 'center')
789
- validate_worksheet
790
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.vertical = alignment }
791
- end
792
-
793
- def change_text_wrap(wrap = false)
794
- validate_worksheet
795
- self.style_index = workbook.modify_alignment(self.style_index) { |a| a.wrap_text = wrap }
796
- end
797
-
798
- def change_border(direction, weight)
799
- validate_worksheet
800
- self.style_index = workbook.modify_border(self.style_index, direction, weight)
801
- end
802
-
803
- def is_italicized()
804
- validate_worksheet
805
- get_cell_font.is_italic
806
- end
807
-
808
- def is_bolded()
809
- validate_worksheet
810
- get_cell_font.is_bold
811
- end
812
-
813
- def is_underlined()
814
- validate_worksheet
815
- get_cell_font.is_underlined
816
- end
817
-
818
- def is_struckthrough()
819
- validate_worksheet
820
- get_cell_font.is_strikethrough
821
- end
822
-
823
- def font_name()
824
- validate_worksheet
825
- get_cell_font.get_name
826
- end
827
-
828
- def font_size()
829
- validate_worksheet
830
- get_cell_font.get_size
831
- end
832
-
833
- def font_color()
834
- validate_worksheet
835
- get_cell_font.get_rgb_color || '000000'
836
- end
837
-
838
- def fill_color()
839
- validate_worksheet
840
- return workbook.get_fill_color(get_cell_xf)
841
- end
842
-
843
- def horizontal_alignment()
844
- validate_worksheet
845
- xf_obj = get_cell_xf
846
- return nil if xf_obj.alignment.nil?
847
- xf_obj.alignment.horizontal
848
- end
849
-
850
- def vertical_alignment()
851
- validate_worksheet
852
- xf_obj = get_cell_xf
853
- return nil if xf_obj.alignment.nil?
854
- xf_obj.alignment.vertical
855
- end
856
-
857
- def text_wrap()
858
- validate_worksheet
859
- xf_obj = get_cell_xf
860
- return nil if xf_obj.alignment.nil?
861
- xf_obj.alignment.wrap_text
862
- end
863
-
864
- def set_number_format(format_code)
865
- new_xf = get_cell_xf.dup
866
- new_xf.num_fmt_id = workbook.stylesheet.register_number_format(format_code)
867
- new_xf.apply_number_format = true
868
- self.style_index = workbook.register_new_xf(new_xf)
869
- end
870
-
871
- # Changes fill color of cell
872
- def change_fill(rgb = 'ffffff')
873
- validate_worksheet
874
- Color.validate_color(rgb)
875
- self.style_index = workbook.modify_fill(self.style_index, rgb)
876
- end
877
-
878
- # Changes font name of cell
879
- def change_font_name(new_font_name = 'Verdana')
880
- validate_worksheet
881
-
882
- font = get_cell_font.dup
883
- font.set_name(new_font_name)
884
- update_font_references(font)
885
- end
886
-
887
- # Changes font size of cell
888
- def change_font_size(font_size = 10)
889
- validate_worksheet
890
- raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)
891
-
892
- font = get_cell_font.dup
893
- font.set_size(font_size)
894
- update_font_references(font)
895
- end
896
-
897
- # Changes font color of cell
898
- def change_font_color(font_color = '000000')
899
- validate_worksheet
900
- Color.validate_color(font_color)
901
-
902
- font = get_cell_font.dup
903
- font.set_rgb_color(font_color)
904
- update_font_references(font)
905
- end
906
-
907
- # Changes font italics settings of cell
908
- def change_font_italics(italicized = false)
909
- validate_worksheet
910
-
911
- font = get_cell_font.dup
912
- font.set_italic(italicized)
913
- update_font_references(font)
914
- end
915
-
916
- # Changes font bold settings of cell
917
- def change_font_bold(bolded = false)
918
- validate_worksheet
919
-
920
- font = get_cell_font.dup
921
- font.set_bold(bolded)
922
- update_font_references(font)
923
- end
924
-
925
- # Changes font underline settings of cell
926
- def change_font_underline(underlined = false)
927
- validate_worksheet
928
-
929
- font = get_cell_font.dup
930
- font.set_underline(underlined)
931
- update_font_references(font)
932
- end
933
-
934
- def change_font_strikethrough(struckthrough = false)
935
- validate_worksheet
936
-
937
- font = get_cell_font.dup
938
- font.set_strikethrough(struckthrough)
939
- update_font_references(font)
940
- end
941
-
942
- # Helper method to update the font array and xf array
943
- def update_font_references(modified_font)
944
- xf = workbook.register_new_font(modified_font, get_cell_xf)
945
- self.style_index = workbook.register_new_xf(xf)
946
- end
947
- private :update_font_references
948
-
949
- # Performs correct modification based on what type of change_type is specified
950
- def font_switch(change_type, arg)
951
- case change_type
952
- when Worksheet::NAME then change_font_name(arg)
953
- when Worksheet::SIZE then change_font_size(arg)
954
- when Worksheet::COLOR then change_font_color(arg)
955
- when Worksheet::ITALICS then change_font_italics(arg)
956
- when Worksheet::BOLD then change_font_bold(arg)
957
- when Worksheet::UNDERLINE then change_font_underline(arg)
958
- when Worksheet::STRIKETHROUGH then change_font_strikethrough(arg)
959
- else raise 'Invalid change_type'
960
- end
961
- end
962
-
963
- =begin
964
- def add_hyperlink(l)
965
- worksheet.hyperlinks ||= RubyXL::Hyperlinks.new
966
- worksheet.hyperlinks << RubyXL::Hyperlink.new(:ref => self.r, :location => l)
967
- # define_attribute(:'r:id', :string)
968
- # define_attribute(:location, :string)
969
- # define_attribute(:tooltip, :string)
970
- # define_attribute(:display, :string)
971
-
972
- end
973
-
974
- def add_shared_string(str)
975
- self.datatype = RubyXL::DataType::SHARED_STRING
976
- self.raw_value = @workbook.shared_strings_container.add(str)
977
- end
978
- =end
979
-
980
- end
981
-
982
- 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'