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,457 +1,468 @@
1
1
  require 'spec_helper'
2
+ require 'rubyXL/convenience_methods/worksheet'
2
3
 
3
- describe RubyXL::Worksheet do
4
- before do
5
- @workbook = RubyXL::Workbook.new
6
- @worksheet = @workbook.add_worksheet
4
+ SKIP_ROW_COL = 3
7
5
 
8
- (0..10).each do |i|
9
- (0..10).each do |j|
10
- @worksheet.add_cell(i, j, "#{i}:#{j}", "F#{i}:#{j}")
6
+ describe RubyXL::Worksheet do
7
+ subject do
8
+ workbook = RubyXL::Workbook.new
9
+ worksheet = workbook.add_worksheet
10
+
11
+ (0..10).each do |y|
12
+ (0..10).each do |x|
13
+ next if y == SKIP_ROW_COL || x == SKIP_ROW_COL # Skip some rows/cells
14
+ worksheet.add_cell(y, x, "#{x}:#{y}", "F#{x}:#{y}")
11
15
  end
12
16
  end
13
17
 
14
- @old_cell = @worksheet[0][0]
15
- @old_cell_value = @worksheet[0][0].value.to_s
16
- @old_cell_formula = @worksheet[0][0].formula.expression.to_s
18
+ worksheet
19
+ end
20
+
21
+ describe 'addressing cells' do
22
+ it 'should be able to address cells by row and column indices' do
23
+ expect(subject[2][4].value).to eq('4:2')
24
+ end
25
+
26
+ it 'should be able to address cells by reference' do
27
+ expect(subject.cell_at('B5').value).to eq('1:4')
28
+ end
17
29
  end
18
30
 
19
31
  describe '.change_row_fill' do
20
32
  it 'should raise error if hex color code not passed' do
21
33
  expect {
22
- @worksheet.change_row_fill(0, 'G')
34
+ subject.change_row_fill(0, 'G')
23
35
  }.to raise_error(RuntimeError)
24
36
  end
25
37
 
26
38
  it 'should raise error if hex color code includes # character' do
27
39
  expect {
28
- @worksheet.change_row_fill(3, '#FFF000')
40
+ subject.change_row_fill(3, '#FFF000')
29
41
  }.to raise_error(RuntimeError)
30
42
  end
31
43
 
32
44
  it 'should make row and cell fill colors equal hex color code passed' do
33
- @worksheet.change_row_fill(0, '111111')
34
- expect(@worksheet.get_row_fill(0)).to eq('111111')
35
- expect(@worksheet[0][5].fill_color).to eq('111111')
45
+ subject.change_row_fill(0, '111111')
46
+ expect(subject.get_row_fill(0)).to eq('111111')
47
+ expect(subject[0][5].fill_color).to eq('111111')
36
48
  end
37
49
 
38
50
  it 'should cause error if a negative argument is passed in' do
39
51
  expect {
40
- @worksheet.change_row_fill(-1, '111111')
52
+ subject.change_row_fill(-1, '111111')
41
53
  }.to raise_error(RuntimeError)
42
54
  end
43
55
 
44
56
  it 'should create a new row if it did not exist before' do
45
- expect(@worksheet.sheet_data[11]).to be_nil
46
- @worksheet.change_row_fill(11, '111111')
47
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
48
- expect(@worksheet.get_row_fill(11)).to eq('111111')
57
+ expect(subject.sheet_data[11]).to be_nil
58
+ subject.change_row_fill(11, '111111')
59
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
60
+ expect(subject.get_row_fill(11)).to eq('111111')
49
61
  end
50
62
  end
51
63
 
52
64
  describe '.change_row_font_name' do
53
65
  it 'should make row and cell font names equal font name passed' do
54
- @worksheet.change_row_font_name(0, 'Arial')
55
- expect(@worksheet.get_row_font_name(0)).to eq('Arial')
56
- expect(@worksheet[0][5].font_name).to eq('Arial')
66
+ subject.change_row_font_name(0, 'Arial')
67
+ expect(subject.get_row_font_name(0)).to eq('Arial')
68
+ expect(subject[0][5].font_name).to eq('Arial')
57
69
  end
58
70
 
59
71
  it 'should cause error if a negative argument is passed in' do
60
72
  expect {
61
- @worksheet.change_row_font_name(-1, 'Arial')
73
+ subject.change_row_font_name(-1, 'Arial')
62
74
  }.to raise_error(RuntimeError)
63
75
  end
64
76
 
65
77
  it 'should create a new row if it did not exist before' do
66
- expect(@worksheet.sheet_data[11]).to be_nil
67
- @worksheet.change_row_font_name(11, 'Arial')
68
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
69
- expect(@worksheet.get_row_font_name(11)).to eq("Arial")
78
+ expect(subject.sheet_data[11]).to be_nil
79
+ subject.change_row_font_name(11, 'Arial')
80
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
81
+ expect(subject.get_row_font_name(11)).to eq('Arial')
70
82
  end
71
83
  end
72
84
 
73
85
  describe '.change_row_font_size' do
74
86
  it 'should make row and cell font sizes equal font number passed' do
75
- @worksheet.change_row_font_size(0, 20)
76
- expect(@worksheet.get_row_font_size(0)).to eq(20)
77
- expect(@worksheet[0][5].font_size).to eq(20)
87
+ subject.change_row_font_size(0, 20)
88
+ expect(subject.get_row_font_size(0)).to eq(20)
89
+ expect(subject[0][5].font_size).to eq(20)
78
90
  end
79
91
 
80
92
  it 'should cause an error if a string passed' do
81
93
  expect {
82
- @worksheet.change_row_font_size(0, '20')
94
+ subject.change_row_font_size(0, '20')
83
95
  }.to raise_error(RuntimeError)
84
96
  end
85
97
 
86
98
  it 'should cause error if a negative argument is passed in' do
87
99
  expect {
88
- @worksheet.change_row_font_size(-1,20)
100
+ subject.change_row_font_size(-1, 20)
89
101
  }.to raise_error(RuntimeError)
90
102
  end
91
103
 
92
104
  it 'should create a new row if it did not exist before' do
93
- expect(@worksheet.sheet_data[11]).to be_nil
94
- @worksheet.change_row_font_size(11,20)
95
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
96
- expect(@worksheet.get_row_font_size(11)).to eq(20)
105
+ expect(subject.sheet_data[11]).to be_nil
106
+ subject.change_row_font_size(11, 20)
107
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
108
+ expect(subject.get_row_font_size(11)).to eq(20)
97
109
  end
98
110
  end
99
111
 
100
112
  describe '.change_row_font_color' do
101
113
  it 'should make row and cell font colors equal to font color passed' do
102
- @worksheet.change_row_font_color(0, '0f0f0f')
103
- expect(@worksheet.get_row_font_color(0)).to eq('0f0f0f')
104
- expect(@worksheet[0][5].font_color).to eq('0f0f0f')
114
+ subject.change_row_font_color(0, '0f0f0f')
115
+ expect(subject.get_row_font_color(0)).to eq('0f0f0f')
116
+ expect(subject[0][5].font_color).to eq('0f0f0f')
105
117
  end
106
118
 
107
119
  it 'should raise error if hex color code not passed' do
108
120
  expect {
109
- @worksheet.change_row_font_color(0, 'G')
121
+ subject.change_row_font_color(0, 'G')
110
122
  }.to raise_error(RuntimeError)
111
123
  end
112
124
 
113
125
  it 'should raise error if hex color code includes # character' do
114
126
  expect {
115
- @worksheet.change_row_font_color(3, '#FFF000')
127
+ subject.change_row_font_color(3, '#FFF000')
116
128
  }.to raise_error(RuntimeError)
117
129
  end
118
130
 
119
131
  it 'should cause error if a negative argument is passed in' do
120
132
  expect {
121
- @worksheet.change_row_font_color(-1, '0f0f0f')
133
+ subject.change_row_font_color(-1, '0f0f0f')
122
134
  }.to raise_error(RuntimeError)
123
135
  end
124
136
 
125
137
  it 'should create a new row if it did not exist before' do
126
- expect(@worksheet.sheet_data[11]).to be_nil
127
- @worksheet.change_row_font_color(11, '0f0f0f')
128
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
129
- expect(@worksheet.get_row_font_color(11)).to eq('0f0f0f')
138
+ expect(subject.sheet_data[11]).to be_nil
139
+ subject.change_row_font_color(11, '0f0f0f')
140
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
141
+ expect(subject.get_row_font_color(11)).to eq('0f0f0f')
130
142
  end
131
143
  end
132
144
 
133
145
  describe '.change_row_italics' do
134
146
  it 'should make row and cell fonts italicized when true is passed' do
135
- @worksheet.change_row_italics(0, true)
136
- expect(@worksheet.is_row_italicized(0)).to eq(true)
137
- expect(@worksheet[0][5].is_italicized).to eq(true)
147
+ subject.change_row_italics(0, true)
148
+ expect(subject.is_row_italicized(0)).to eq(true)
149
+ expect(subject[0][5].is_italicized).to eq(true)
138
150
  end
139
151
 
140
152
  it 'should cause error if a negative argument is passed in' do
141
153
  expect {
142
- @worksheet.change_row_italics(-1, false)
154
+ subject.change_row_italics(-1, false)
143
155
  }.to raise_error(RuntimeError)
144
156
  end
145
157
 
146
158
  it 'should create a new row if it did not exist before' do
147
- expect(@worksheet.sheet_data[11]).to be_nil
148
- @worksheet.change_row_italics(11,true)
149
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
150
- expect(@worksheet.is_row_italicized(11)).to eq(true)
159
+ expect(subject.sheet_data[11]).to be_nil
160
+ subject.change_row_italics(11, true)
161
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
162
+ expect(subject.is_row_italicized(11)).to eq(true)
151
163
  end
152
164
  end
153
165
 
154
166
  describe '.change_row_bold' do
155
167
  it 'should make row and cell fonts bolded when true is passed' do
156
- @worksheet.change_row_bold(0, true)
157
- expect(@worksheet.is_row_bolded(0)).to eq(true)
158
- expect(@worksheet[0][5].is_bolded).to eq(true)
168
+ subject.change_row_bold(0, true)
169
+ expect(subject.is_row_bolded(0)).to eq(true)
170
+ expect(subject[0][5].is_bolded).to eq(true)
159
171
  end
160
172
 
161
173
  it 'should cause error if a negative argument is passed in' do
162
174
  expect {
163
- @worksheet.change_row_bold(-1, false)
175
+ subject.change_row_bold(-1, false)
164
176
  }.to raise_error(RuntimeError)
165
177
  end
166
178
 
167
179
  it 'should create a new row if it did not exist before' do
168
- expect(@worksheet.sheet_data[11]).to be_nil
169
- @worksheet.change_row_bold(11, true)
170
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
171
- expect(@worksheet.is_row_bolded(11)).to eq(true)
180
+ expect(subject.sheet_data[11]).to be_nil
181
+ subject.change_row_bold(11, true)
182
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
183
+ expect(subject.is_row_bolded(11)).to eq(true)
172
184
  end
173
185
  end
174
186
 
175
187
  describe '.change_row_underline' do
176
188
  it 'should make row and cell fonts underlined when true is passed' do
177
- @worksheet.change_row_underline(0, true)
178
- expect(@worksheet.is_row_underlined(0)).to eq(true)
179
- expect(@worksheet[0][5].is_underlined).to eq(true)
189
+ subject.change_row_underline(0, true)
190
+ expect(subject.is_row_underlined(0)).to eq(true)
191
+ expect(subject[0][5].is_underlined).to eq(true)
180
192
  end
181
193
 
182
194
  it 'should cause error if a negative argument is passed in' do
183
195
  expect {
184
- @worksheet.change_row_underline(-1, false)
196
+ subject.change_row_underline(-1, false)
185
197
  }.to raise_error(RuntimeError)
186
198
  end
187
199
 
188
200
  it 'should create a new row if it did not exist before' do
189
- expect(@worksheet.sheet_data[11]).to be_nil
190
- @worksheet.change_row_underline(11,true)
191
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
192
- expect(@worksheet.is_row_underlined(11)).to eq(true)
201
+ expect(subject.sheet_data[11]).to be_nil
202
+ subject.change_row_underline(11, true)
203
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
204
+ expect(subject.is_row_underlined(11)).to eq(true)
193
205
  end
194
206
  end
195
207
 
196
208
  describe '.change_row_strikethrough' do
197
209
  it 'should make row and cell fonts struckthrough when true is passed' do
198
- @worksheet.change_row_strikethrough(0, true)
199
- expect(@worksheet.is_row_struckthrough(0)).to eq(true)
200
- expect(@worksheet[0][5].is_struckthrough).to eq(true)
210
+ subject.change_row_strikethrough(0, true)
211
+ expect(subject.is_row_struckthrough(0)).to eq(true)
212
+ expect(subject[0][5].is_struckthrough).to eq(true)
201
213
  end
202
214
 
203
215
  it 'should cause error if a negative argument is passed in' do
204
216
  expect {
205
- @worksheet.change_row_strikethrough(-1, false)
217
+ subject.change_row_strikethrough(-1, false)
206
218
  }.to raise_error(RuntimeError)
207
219
  end
208
220
 
209
221
  it 'should create a new row if it did not exist before' do
210
- expect(@worksheet.sheet_data[11]).to be_nil
211
- @worksheet.change_row_strikethrough(11,true)
212
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
213
- expect(@worksheet.is_row_struckthrough(11)).to eq(true)
222
+ expect(subject.sheet_data[11]).to be_nil
223
+ subject.change_row_strikethrough(11, true)
224
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
225
+ expect(subject.is_row_struckthrough(11)).to eq(true)
214
226
  end
215
227
  end
216
228
 
217
229
  describe '.change_row_height' do
218
230
  it 'should make row height match number which is passed' do
219
- @worksheet.change_row_height(0,30.0002)
220
- expect(@worksheet.get_row_height(0)).to eq(30.0002)
231
+ subject.change_row_height(0, 30.0002)
232
+ expect(subject.get_row_height(0)).to eq(30.0002)
221
233
  end
222
234
 
223
235
  it 'should make row height a number equivalent of the string passed if it is a string which is a number' do
224
- @worksheet.change_row_height(0, 30.0002)
225
- expect(@worksheet.get_row_height(0)).to eq(30.0002)
236
+ subject.change_row_height(0, 30.0002)
237
+ expect(subject.get_row_height(0)).to eq(30.0002)
226
238
  end
227
239
 
228
240
  it 'should cause error if a negative argument is passed in' do
229
241
  expect {
230
- @worksheet.change_row_height(-1, 30)
242
+ subject.change_row_height(-1, 30)
231
243
  }.to raise_error(RuntimeError)
232
244
  end
233
245
 
234
246
  it 'should create a new row if it did not exist before' do
235
- expect(@worksheet.sheet_data[11]).to be_nil
236
- @worksheet.change_row_height(11, 30)
237
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
238
- expect(@worksheet.get_row_height(11)).to eq(30)
247
+ expect(subject.sheet_data[11]).to be_nil
248
+ subject.change_row_height(11, 30)
249
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
250
+ expect(subject.get_row_height(11)).to eq(30)
239
251
  end
240
252
  end
241
253
 
242
254
  describe '.change_row_horizontal_alignment' do
243
255
  it 'should cause row and cells to horizontally align as specified by the passed in string' do
244
- @worksheet.change_row_horizontal_alignment(0, 'center')
245
- expect(@worksheet.get_row_alignment(0, true)).to eq('center')
246
- expect(@worksheet[0][5].horizontal_alignment).to eq('center')
256
+ subject.change_row_horizontal_alignment(0, 'center')
257
+ expect(subject.get_row_alignment(0, true)).to eq('center')
258
+ expect(subject[0][5].horizontal_alignment).to eq('center')
247
259
  end
248
260
 
249
261
  it 'should cause error if a negative argument is passed in' do
250
262
  expect {
251
- @worksheet.change_row_horizontal_alignment(-1, 'center')
263
+ subject.change_row_horizontal_alignment(-1, 'center')
252
264
  }.to raise_error(RuntimeError)
253
265
  end
254
266
 
255
267
  it 'should create a new row if it did not exist before' do
256
- expect(@worksheet.sheet_data[11]).to be_nil
257
- @worksheet.change_row_horizontal_alignment(11, 'center')
258
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
259
- expect(@worksheet.get_row_alignment(11, true)).to eq('center')
268
+ expect(subject.sheet_data[11]).to be_nil
269
+ subject.change_row_horizontal_alignment(11, 'center')
270
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
271
+ expect(subject.get_row_alignment(11, true)).to eq('center')
260
272
  end
261
273
  end
262
274
 
263
275
  describe '.change_row_vertical_alignment' do
264
276
  it 'should cause row and cells to vertically align as specified by the passed in string' do
265
- @worksheet.change_row_vertical_alignment(0, 'center')
266
- expect(@worksheet.get_row_alignment(0, false)).to eq('center')
267
- expect(@worksheet[0][5].vertical_alignment).to eq('center')
277
+ subject.change_row_vertical_alignment(0, 'center')
278
+ expect(subject.get_row_alignment(0, false)).to eq('center')
279
+ expect(subject[0][5].vertical_alignment).to eq('center')
268
280
  end
269
281
 
270
282
  it 'should cause error if a negative argument is passed in' do
271
283
  expect {
272
- @worksheet.change_row_vertical_alignment(-1, 'center')
284
+ subject.change_row_vertical_alignment(-1, 'center')
273
285
  }.to raise_error(RuntimeError)
274
286
  end
275
287
 
276
288
  it 'should create a new row if it did not exist before' do
277
- expect(@worksheet.sheet_data[11]).to be_nil
278
- @worksheet.change_row_vertical_alignment(11, 'center')
279
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
280
- expect(@worksheet.get_row_alignment(11, false)).to eq('center')
289
+ expect(subject.sheet_data[11]).to be_nil
290
+ subject.change_row_vertical_alignment(11, 'center')
291
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
292
+ expect(subject.get_row_alignment(11, false)).to eq('center')
281
293
  end
282
294
  end
283
295
 
284
296
  describe '.change_row_border' do
285
-
286
297
  it 'should cause error if a negative argument is passed in' do
287
298
  expect {
288
- @worksheet.change_row_border(-1, :left, 'thin')
299
+ subject.change_row_border(-1, :left, 'thin')
289
300
  }.to raise_error(RuntimeError)
290
301
  end
291
302
 
292
303
  it 'should create a new row if it did not exist before' do
293
- expect(@worksheet.sheet_data[11]).to be_nil
294
- @worksheet.change_row_border(11, :left, 'thin')
295
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
296
- expect(@worksheet.get_row_border(11, :left)).to eq('thin')
304
+ expect(subject.sheet_data[11]).to be_nil
305
+ subject.change_row_border(11, :left, 'thin')
306
+ expect(subject.sheet_data[11]).to be_a(RubyXL::Row)
307
+ expect(subject.get_row_border(11, :left)).to eq('thin')
297
308
  end
298
309
 
299
310
  it 'should cause row and cells to have border at top of specified weight' do
300
- @worksheet.change_row_border(0, :top, 'thin')
301
- expect(@worksheet.get_row_border(0, :top)).to eq('thin')
302
- expect(@worksheet[0][5].get_border(:top)).to eq('thin')
311
+ subject.change_row_border(0, :top, 'thin')
312
+ expect(subject.get_row_border(0, :top)).to eq('thin')
313
+ expect(subject[0][5].get_border(:top)).to eq('thin')
303
314
  end
304
315
 
305
316
  it 'should cause row and cells to have border at left of specified weight' do
306
- @worksheet.change_row_border(0, :left, 'thin')
307
- expect(@worksheet.get_row_border(0, :left)).to eq('thin')
308
- expect(@worksheet[0][5].get_border(:left)).to eq('thin')
317
+ subject.change_row_border(0, :left, 'thin')
318
+ expect(subject.get_row_border(0, :left)).to eq('thin')
319
+ expect(subject[0][5].get_border(:left)).to eq('thin')
309
320
  end
310
321
 
311
322
  it 'should cause row and cells to have border at right of specified weight' do
312
- @worksheet.change_row_border(0, :right, 'thin')
313
- expect(@worksheet.get_row_border(0, :right)).to eq('thin')
314
- expect(@worksheet[0][5].get_border(:right)).to eq('thin')
323
+ subject.change_row_border(0, :right, 'thin')
324
+ expect(subject.get_row_border(0, :right)).to eq('thin')
325
+ expect(subject[0][5].get_border(:right)).to eq('thin')
315
326
  end
316
327
 
317
328
  it 'should cause row to have border at bottom of specified weight' do
318
- @worksheet.change_row_border(0, :bottom, 'thin')
319
- expect(@worksheet.get_row_border(0, :bottom)).to eq('thin')
320
- expect(@worksheet[0][5].get_border(:bottom)).to eq('thin')
329
+ subject.change_row_border(0, :bottom, 'thin')
330
+ expect(subject.get_row_border(0, :bottom)).to eq('thin')
331
+ expect(subject[0][5].get_border(:bottom)).to eq('thin')
321
332
  end
322
333
 
323
334
  it 'should cause row to have border at diagonal of specified weight' do
324
- @worksheet.change_row_border(0, :diagonal, 'thin')
325
- expect(@worksheet.get_row_border(0, :diagonal)).to eq('thin')
326
- expect(@worksheet[0][5].get_border(:diagonal)).to eq('thin')
335
+ subject.change_row_border(0, :diagonal, 'thin')
336
+ expect(subject.get_row_border(0, :diagonal)).to eq('thin')
337
+ expect(subject[0][5].get_border(:diagonal)).to eq('thin')
327
338
  end
328
339
  end
329
340
 
330
341
  describe '.change_column_font_name' do
331
342
  it 'should cause column and cell font names to match string passed in' do
332
- @worksheet.change_column_font_name(0, 'Arial')
333
- expect(@worksheet.get_column_font_name(0)).to eq('Arial')
334
- expect(@worksheet[5][0].font_name).to eq('Arial')
343
+ subject.change_column_font_name(0, 'Arial')
344
+ expect(subject.get_column_font_name(0)).to eq('Arial')
345
+ expect(subject[5][0].font_name).to eq('Arial')
335
346
  end
336
347
 
337
348
  it 'should cause error if a negative argument is passed in' do
338
349
  expect {
339
- @worksheet.change_column_font_name(-1, 'Arial')
350
+ subject.change_column_font_name(-1, 'Arial')
340
351
  }.to raise_error(RuntimeError)
341
352
  end
342
353
  end
343
354
 
344
355
  describe '.change_column_font_size' do
345
356
  it 'should make column and cell font sizes equal font number passed' do
346
- @worksheet.change_column_font_size(0, 20)
347
- expect(@worksheet.get_column_font_size(0)).to eq(20)
348
- expect(@worksheet[5][0].font_size).to eq(20)
357
+ subject.change_column_font_size(0, 20)
358
+ expect(subject.get_column_font_size(0)).to eq(20)
359
+ expect(subject[5][0].font_size).to eq(20)
349
360
  end
350
361
 
351
362
  it 'should cause an error if a string passed' do
352
363
  expect {
353
- @worksheet.change_column_font_size(0, '20')
364
+ subject.change_column_font_size(0, '20')
354
365
  }.to raise_error(RuntimeError)
355
366
  end
356
367
 
357
368
  it 'should cause error if a negative argument is passed in' do
358
369
  expect {
359
- @worksheet.change_column_font_size(-1, 20)
370
+ subject.change_column_font_size(-1, 20)
360
371
  }.to raise_error(RuntimeError)
361
372
  end
362
373
  end
363
374
 
364
375
  describe '.change_column_font_color' do
365
376
  it 'should make column and cell font colors equal to font color passed' do
366
- @worksheet.change_column_font_color(0, '0f0f0f')
367
- expect(@worksheet.get_column_font_color(0)).to eq('0f0f0f')
368
- expect(@worksheet[5][0].font_color).to eq('0f0f0f')
377
+ subject.change_column_font_color(0, '0f0f0f')
378
+ expect(subject.get_column_font_color(0)).to eq('0f0f0f')
379
+ expect(subject[5][0].font_color).to eq('0f0f0f')
369
380
  end
370
381
 
371
382
  it 'should raise error if hex color code not passed' do
372
383
  expect {
373
- @worksheet.change_column_font_color(0, 'G')
384
+ subject.change_column_font_color(0, 'G')
374
385
  }.to raise_error(RuntimeError)
375
386
  end
376
387
 
377
388
  it 'should raise error if hex color code includes # character' do
378
389
  expect {
379
- @worksheet.change_column_font_color(0, '#FFF000')
390
+ subject.change_column_font_color(0, '#FFF000')
380
391
  }.to raise_error(RuntimeError)
381
392
  end
382
393
 
383
394
  it 'should cause error if a negative argument is passed in' do
384
395
  expect {
385
- @worksheet.change_column_font_color(-1, '0f0f0f')
396
+ subject.change_column_font_color(-1, '0f0f0f')
386
397
  }.to raise_error(RuntimeError)
387
398
  end
388
399
  end
389
400
 
390
401
  describe '.change_column_italics' do
391
402
  it 'should make column and cell fonts italicized when true is passed' do
392
- @worksheet.change_column_italics(0, true)
393
- expect(@worksheet.is_column_italicized(0)).to eq(true)
394
- expect(@worksheet[5][0].is_italicized).to eq(true)
403
+ subject.change_column_italics(0, true)
404
+ expect(subject.is_column_italicized(0)).to eq(true)
405
+ expect(subject[5][0].is_italicized).to eq(true)
395
406
  end
396
407
 
397
408
  it 'should cause error if a negative argument is passed in' do
398
409
  expect {
399
- @worksheet.change_column_italics(-1, false)
410
+ subject.change_column_italics(-1, false)
400
411
  }.to raise_error(RuntimeError)
401
412
  end
402
413
  end
403
414
 
404
415
  describe '.change_column_bold' do
405
416
  it 'should make column and cell fonts bolded when true is passed' do
406
- @worksheet.change_column_bold(0, true)
407
- expect(@worksheet.is_column_bolded(0)).to eq(true)
408
- expect(@worksheet[5][0].is_bolded).to eq(true)
417
+ subject.change_column_bold(0, true)
418
+ expect(subject.is_column_bolded(0)).to eq(true)
419
+ expect(subject[5][0].is_bolded).to eq(true)
409
420
  end
410
421
 
411
422
  it 'should cause error if a negative argument is passed in' do
412
423
  expect {
413
- @worksheet.change_column_bold(-1, false)
424
+ subject.change_column_bold(-1, false)
414
425
  }.to raise_error(RuntimeError)
415
426
  end
416
427
  end
417
428
 
418
429
  describe '.change_column_underline' do
419
430
  it 'should make column and cell fonts underlined when true is passed' do
420
- @worksheet.change_column_underline(0, true)
421
- expect(@worksheet.is_column_underlined(0)).to eq(true)
422
- expect(@worksheet[5][0].is_underlined).to eq(true)
431
+ subject.change_column_underline(0, true)
432
+ expect(subject.is_column_underlined(0)).to eq(true)
433
+ expect(subject[5][0].is_underlined).to eq(true)
423
434
  end
424
435
 
425
436
  it 'should cause error if a negative argument is passed in' do
426
437
  expect {
427
- @worksheet.change_column_underline(-1, false)
438
+ subject.change_column_underline(-1, false)
428
439
  }.to raise_error(RuntimeError)
429
440
  end
430
441
  end
431
442
 
432
443
  describe '.change_column_strikethrough' do
433
444
  it 'should make column and cell fonts struckthrough when true is passed' do
434
- @worksheet.change_column_strikethrough(0, true)
435
- expect(@worksheet.is_column_struckthrough(0)).to eq(true)
436
- expect(@worksheet[5][0].is_struckthrough).to eq(true)
445
+ subject.change_column_strikethrough(0, true)
446
+ expect(subject.is_column_struckthrough(0)).to eq(true)
447
+ expect(subject[5][0].is_struckthrough).to eq(true)
437
448
  end
438
449
 
439
450
  it 'should cause error if a negative argument is passed in' do
440
451
  expect {
441
- @worksheet.change_column_strikethrough(-1, false)
452
+ subject.change_column_strikethrough(-1, false)
442
453
  }.to raise_error(RuntimeError)
443
454
  end
444
455
  end
445
456
 
446
457
  describe '.change_column_width_raw' do
447
458
  it 'should make column width match number which is passed' do
448
- @worksheet.change_column_width_raw(0, 30.0002)
449
- expect(@worksheet.get_column_width_raw(0)).to eq(30.0002)
459
+ subject.change_column_width_raw(0, 30.0002)
460
+ expect(subject.get_column_width_raw(0)).to eq(30.0002)
450
461
  end
451
462
 
452
463
  it 'should cause error if a negative argument is passed in' do
453
464
  expect {
454
- @worksheet.change_column_width_raw(-1, 10)
465
+ subject.change_column_width_raw(-1, 10)
455
466
  }.to raise_error(RuntimeError)
456
467
  end
457
468
  end
@@ -459,314 +470,622 @@ describe RubyXL::Worksheet do
459
470
  describe '.change_column_fill' do
460
471
  it 'should raise error if hex color code not passed' do
461
472
  expect {
462
- @worksheet.change_column_fill(0, 'G')
473
+ subject.change_column_fill(0, 'G')
463
474
  }.to raise_error(RuntimeError)
464
475
  end
465
476
 
466
477
  it 'should raise error if hex color code includes # character' do
467
478
  expect {
468
- @worksheet.change_column_fill(3, '#FFF000')
479
+ subject.change_column_fill(3, '#FFF000')
469
480
  }.to raise_error(RuntimeError)
470
481
  end
471
482
 
472
483
  it 'should make column and cell fill colors equal hex color code passed' do
473
- @worksheet.change_column_fill(0, '111111')
474
- expect(@worksheet.get_column_fill(0)).to eq('111111')
475
- expect(@worksheet[5][0].fill_color).to eq('111111')
484
+ subject.change_column_fill(0, '111111')
485
+ expect(subject.get_column_fill(0)).to eq('111111')
486
+ expect(subject[5][0].fill_color).to eq('111111')
476
487
  end
477
488
 
478
489
  it 'should cause error if a negative argument is passed in' do
479
490
  expect {
480
- @worksheet.change_column_fill(-1, '111111')
491
+ subject.change_column_fill(-1, '111111')
481
492
  }.to raise_error(RuntimeError)
482
493
  end
483
494
  end
484
495
 
485
496
  describe '.change_column_horizontal_alignment' do
486
497
  it 'should cause column and cell to horizontally align as specified by the passed in string' do
487
- @worksheet.change_column_horizontal_alignment(0, 'center')
488
- expect(@worksheet.get_column_alignment(0, :horizontal)).to eq('center')
489
- expect(@worksheet[5][0].horizontal_alignment).to eq('center')
498
+ subject.change_column_horizontal_alignment(0, 'center')
499
+ expect(subject.get_column_alignment(0, :horizontal)).to eq('center')
500
+ expect(subject[5][0].horizontal_alignment).to eq('center')
490
501
  end
491
502
 
492
503
  it 'should cause error if a negative argument is passed in' do
493
504
  expect {
494
- @worksheet.change_column_horizontal_alignment(-1, 'center')
505
+ subject.change_column_horizontal_alignment(-1, 'center')
495
506
  }.to raise_error(RuntimeError)
496
507
  end
497
508
  end
498
509
 
499
510
  describe '.change_column_vertical_alignment' do
500
511
  it 'should cause column and cell to vertically align as specified by the passed in string' do
501
- @worksheet.change_column_vertical_alignment(0, 'center')
502
- expect(@worksheet.get_column_alignment(0, :vertical)).to eq('center')
503
- expect(@worksheet[5][0].vertical_alignment).to eq('center')
512
+ subject.change_column_vertical_alignment(0, 'center')
513
+ expect(subject.get_column_alignment(0, :vertical)).to eq('center')
514
+ expect(subject[5][0].vertical_alignment).to eq('center')
504
515
  end
505
516
 
506
517
  it 'should cause error if a negative argument is passed in' do
507
518
  expect {
508
- @worksheet.change_column_vertical_alignment(-1, 'center')
519
+ subject.change_column_vertical_alignment(-1, 'center')
509
520
  }.to raise_error(RuntimeError)
510
521
  end
511
522
 
512
523
  it 'should set column width if column alignment is changed' do
513
524
  test_column = 2
514
- expect(@worksheet.get_column_alignment(test_column, :vertical)).to be_nil
515
- expect(@worksheet.get_column_width_raw(test_column)).to be_nil
516
- expect(@worksheet.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
517
- @worksheet.change_column_vertical_alignment(test_column, 'top')
518
- expect(@worksheet.get_column_width_raw(test_column)).not_to be_nil
519
- expect(@worksheet.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
520
- expect(@worksheet.get_column_alignment(test_column, :vertical)).to eq('top')
525
+ expect(subject.get_column_alignment(test_column, :vertical)).to be_nil
526
+ expect(subject.get_column_width_raw(test_column)).to be_nil
527
+ expect(subject.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
528
+ subject.change_column_vertical_alignment(test_column, 'top')
529
+ expect(subject.get_column_width_raw(test_column)).not_to be_nil
530
+ expect(subject.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
531
+ expect(subject.get_column_alignment(test_column, :vertical)).to eq('top')
521
532
  end
522
533
  end
523
534
 
524
535
  describe '.change_column_border' do
525
536
  it 'should cause error if a negative argument is passed in' do
526
537
  expect {
527
- @worksheet.change_column_border(-1, :top, 'thin')
538
+ subject.change_column_border(-1, :top, 'thin')
528
539
  }.to raise_error(RuntimeError)
529
540
  end
530
541
 
531
542
  it 'should cause column and cells within to have border at top of specified weight' do
532
- @worksheet.change_column_border(0, :top, 'thin')
533
- expect(@worksheet.get_column_border(0, :top)).to eq('thin')
534
- expect(@worksheet[5][0].get_border(:top)).to eq('thin')
543
+ subject.change_column_border(0, :top, 'thin')
544
+ expect(subject.get_column_border(0, :top)).to eq('thin')
545
+ expect(subject[5][0].get_border(:top)).to eq('thin')
535
546
  end
536
547
 
537
548
  it 'should cause column and cells within to have border at left of specified weight' do
538
- @worksheet.change_column_border(0, :left, 'thin')
539
- expect(@worksheet.get_column_border(0, :left)).to eq('thin')
540
- expect(@worksheet[5][0].get_border(:left)).to eq('thin')
549
+ subject.change_column_border(0, :left, 'thin')
550
+ expect(subject.get_column_border(0, :left)).to eq('thin')
551
+ expect(subject[5][0].get_border(:left)).to eq('thin')
541
552
  end
542
553
 
543
554
  it 'should cause column and cells within to have border at right of specified weight' do
544
- @worksheet.change_column_border(0, :right, 'thin')
545
- expect(@worksheet.get_column_border(0, :right)).to eq('thin')
546
- expect(@worksheet[5][0].get_border(:right)).to eq('thin')
555
+ subject.change_column_border(0, :right, 'thin')
556
+ expect(subject.get_column_border(0, :right)).to eq('thin')
557
+ expect(subject[5][0].get_border(:right)).to eq('thin')
547
558
  end
548
559
 
549
560
  it 'should cause column and cells within to have border at bottom of specified weight' do
550
- @worksheet.change_column_border(0, :bottom, 'thin')
551
- expect(@worksheet.get_column_border(0, :bottom)).to eq('thin')
552
- expect(@worksheet[5][0].get_border(:bottom)).to eq('thin')
561
+ subject.change_column_border(0, :bottom, 'thin')
562
+ expect(subject.get_column_border(0, :bottom)).to eq('thin')
563
+ expect(subject[5][0].get_border(:bottom)).to eq('thin')
553
564
  end
554
565
 
555
566
  it 'should cause column and cells within to have border at diagonal of specified weight' do
556
- @worksheet.change_column_border(0, :diagonal, 'thin')
557
- expect(@worksheet.get_column_border(0, :diagonal)).to eq('thin')
558
- expect(@worksheet[5][0].get_border(:diagonal)).to eq('thin')
567
+ subject.change_column_border(0, :diagonal, 'thin')
568
+ expect(subject.get_column_border(0, :diagonal)).to eq('thin')
569
+ expect(subject[5][0].get_border(:diagonal)).to eq('thin')
559
570
  end
560
571
  end
561
572
 
562
573
  describe '.merge_cells' do
563
574
  it 'should merge cells in any valid range specified by indices' do
564
- @worksheet.merge_cells(0, 0, 1, 1)
565
- expect(@worksheet.merged_cells.collect{ |r| r.ref.to_s }).to eq(["A1:B2"])
575
+ subject.merge_cells(0, 0, 1, 1)
576
+ expect(subject.merged_cells.collect{ |r| r.ref.to_s }).to eq(['A1:B2'])
566
577
  end
567
578
  end
568
579
 
569
580
  describe '.add_cell' do
570
581
  it 'should add new cell where specified, even if a cell is already there (default)' do
571
- @worksheet.add_cell(0,0, 'TEST')
572
- expect(@worksheet[0][0].value).not_to eq(@old_cell_value)
573
- expect(@worksheet[0][0].value).to eq('TEST')
582
+ old_cell = subject[0][0]
583
+ old_cell_value = old_cell.value.to_s
584
+
585
+ subject.add_cell(0, 0, 'TEST')
586
+ expect(subject[0][0].value).not_to eq(old_cell_value)
587
+ expect(subject[0][0].value).to eq('TEST')
574
588
  end
575
589
 
576
590
  it 'should add a new cell below nil rows that might exist' do
577
- @worksheet.sheet_data.rows << nil << nil
578
- @worksheet.add_cell(15,0, 'TEST')
579
- expect(@worksheet[15][0].value).to eq('TEST')
591
+ subject.sheet_data.rows << nil << nil
592
+ subject.add_cell(15, 0, 'TEST')
593
+ expect(subject[15][0].value).to eq('TEST')
580
594
  end
581
595
 
582
596
  it 'should add new cell where specified with formula, even if a cell is already there (default)' do
583
- @worksheet.add_cell(0,0, '', 'SUM(A2:A10)')
584
- expect(@worksheet[0][0].value).not_to eq(@old_cell_value)
585
- expect(@worksheet[0][0].formula).not_to eq(@old_cell_formula)
586
- expect(@worksheet[0][0].value).to eq('')
587
- expect(@worksheet[0][0].formula.expression).to eq('SUM(A2:A10)')
597
+ old_cell = subject[0][0]
598
+ old_cell_value = old_cell.value.to_s
599
+ old_cell_formula = old_cell.formula.expression.to_s
600
+
601
+ subject.add_cell(0, 0, '', 'SUM(A2:A10)')
602
+ expect(subject[0][0].value).not_to eq(old_cell_value)
603
+ expect(subject[0][0].formula).not_to eq(old_cell_formula)
604
+ expect(subject[0][0].value).to eq('')
605
+ expect(subject[0][0].formula.expression).to eq('SUM(A2:A10)')
588
606
  end
589
607
 
590
608
  it 'should not overwrite when a cell is present when overwrite is specified to be false' do
591
- @worksheet.add_cell(0,0, 'TEST', 'B2',false)
592
- expect(@worksheet[0][0].value).to eq(@old_cell_value)
593
- expect(@worksheet[0][0].formula.expression.to_s).to eq(@old_cell_formula)
609
+ old_cell = subject[0][0]
610
+ old_cell_value = old_cell.value.to_s
611
+ old_cell_formula = old_cell.formula.expression.to_s
612
+
613
+ subject.add_cell(0, 0, 'TEST', 'B2', false)
614
+ expect(subject[0][0].value).to eq(old_cell_value)
615
+ expect(subject[0][0].formula.expression.to_s).to eq(old_cell_formula)
594
616
  end
595
617
 
596
618
  it 'should still add a new cell when there is no cell to be overwritten' do
597
- @worksheet.add_cell(11,11, 'TEST', 'B2',false)
598
- expect(@worksheet[11][11].value).to eq('TEST')
599
- expect(@worksheet[11][11].formula.expression).to eq('B2')
619
+ subject.add_cell(11, 11, 'TEST', 'B2', false)
620
+ expect(subject[11][11].value).to eq('TEST')
621
+ expect(subject[11][11].formula.expression).to eq('B2')
600
622
  end
601
623
 
602
624
  it 'should cause error if a negative argument is passed in' do
603
625
  expect {
604
- @worksheet.add_cell(-1,-1, '')
626
+ subject.add_cell(-1, -1, '')
605
627
  }.to raise_error(RuntimeError)
606
628
  end
607
629
  end
608
630
 
609
631
  describe '.delete_row' do
610
632
  it 'should delete a row at index specified, "pushing" everything else "up"' do
611
- @worksheet.delete_row(0)
612
- expect(@worksheet[0][0].value).to eq("1:0")
613
- expect(@worksheet[0][0].formula.expression.to_s).to eq("F1:0")
614
- expect(@worksheet[0][0].row).to eq(0)
615
- expect(@worksheet[0][0].column).to eq(0)
633
+ subject.delete_row(0)
634
+ expect(subject[0][0].value).to eq('0:1')
635
+ expect(subject[0][0].formula.expression.to_s).to eq('F0:1')
636
+ expect(subject[0][0].row).to eq(0)
637
+ expect(subject[0][0].column).to eq(0)
616
638
  end
617
639
 
618
640
  it 'should delete a row at index specified, adjusting styles for other rows' do
619
- @worksheet.change_row_font_name(1,"Courier")
620
- @worksheet.delete_row(0)
621
- expect(@worksheet.get_row_font_name(0)).to eq("Courier")
641
+ subject.change_row_font_name(1, 'Courier')
642
+ subject.delete_row(0)
643
+ expect(subject.get_row_font_name(0)).to eq('Courier')
622
644
  end
623
645
 
624
646
  it 'should preserve (rather than fix) formulas that reference cells in "pushed up" rows' do
625
- @worksheet.add_cell(11, 0, nil, 'SUM(A1:A10)')
626
- @worksheet.delete_row(0)
627
- expect(@worksheet[10][0].formula.expression).to eq('SUM(A1:A10)')
647
+ subject.add_cell(11, 0, nil, 'SUM(A1:A10)')
648
+ subject.delete_row(0)
649
+ expect(subject[10][0].formula.expression).to eq('SUM(A1:A10)')
628
650
  end
629
651
 
630
652
  it 'should cause error if a negative argument is passed in' do
631
653
  expect {
632
- @worksheet.delete_row(-1)
654
+ subject.delete_row(-1)
633
655
  }.to raise_error(RuntimeError)
634
656
  end
635
657
 
636
- it 'should properly reindex the cells' do
637
- @worksheet.sheet_data.rows.each_with_index { |row, r|
638
- row.cells.each_with_index { |cell, c|
639
- expect(cell.row).to eq(r)
640
- expect(cell.column).to eq(c)
641
- }
658
+ it 'should properly reindex the cells' do
659
+ subject.sheet_data.rows.each_with_index { |row, r|
660
+ if (SKIP_ROW_COL == r) then
661
+ expect(row).to be_nil
662
+ else
663
+ row.cells.each_with_index { |cell, c|
664
+ if (SKIP_ROW_COL == c) then
665
+ expect(cell).to be_nil
666
+ else
667
+ expect(cell.row).to eq(r)
668
+ expect(cell.column).to eq(c)
669
+ end
670
+ }
671
+ end
642
672
  }
643
673
  end
674
+
675
+ describe 'merged_cells updating' do
676
+ context 'merged cells in the row' do
677
+ # | A1 | B1 | C1 | D1 | E1 |
678
+ # | A2 | MERGED | E2 |
679
+ # | A3 | B3 | C3 | D3 | E3 |
680
+ before do
681
+ subject.merge_cells(1, 1, 1, 3)
682
+ expect(subject.merged_cells.size).to eq 1
683
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D2'
684
+ end
685
+ it 'should delete merged cell' do
686
+ subject.delete_row(1)
687
+ expect(subject.merged_cells.size).to eq 0
688
+ end
689
+ end
690
+ context 'merged vertical two cells' do
691
+ # | A1 | B1 | C1 |
692
+ # | A2 | MERGED | C2 |
693
+ # | A3 | | C3 |
694
+ # | A4 | B4 | C4 |
695
+ before do
696
+ subject.merge_cells(1, 1, 2, 1)
697
+ expect(subject.merged_cells.size).to eq 1
698
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:B3'
699
+ end
700
+ it 'should delete merged cell' do
701
+ subject.delete_row(1)
702
+ expect(subject.merged_cells.size).to eq 0
703
+ end
704
+ end
705
+
706
+ context 'merged three or more rows' do
707
+ # | A1 | B1 | C1 | D1 | E1 |
708
+ # | A2 | | E2 |
709
+ # | A3 | MERGED | E3 |
710
+ # | A4 | | E4 |
711
+ # | A5 | B5 | C5 | D5 | E5 |
712
+ before do
713
+ subject.merge_cells(1, 1, 3, 3)
714
+ expect(subject.merged_cells.size).to eq 1
715
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D4'
716
+ end
717
+
718
+ # | A2 | | E2 |
719
+ # | A3 | MERGED | E3 |
720
+ # | A4 | | E4 |
721
+ # | A5 | B5 | C5 | D5 | E5 |
722
+ it 'should updates merged cell when delete above the cell' do
723
+ subject.delete_row(0)
724
+ expect(subject.merged_cells.size).to eq 1
725
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B1:D3'
726
+ end
727
+
728
+ # | A1 | B1 | C1 | D1 | E1 |
729
+ # | A3 | MERGED | E3 |
730
+ # | A4 | | E4 |
731
+ # | A5 | B5 | C5 | D5 | E5 |
732
+ it 'should updates merged cell when delete top of the cell' do
733
+ subject.delete_row(1)
734
+ expect(subject.merged_cells.size).to eq 1
735
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D3'
736
+ end
737
+
738
+ # | A1 | B1 | C1 | D1 | E1 |
739
+ # | A2 | MERGED | E2 |
740
+ # | A4 | | E4 |
741
+ # | A5 | B5 | C5 | D5 | E5 |
742
+ it 'should updates merged cell when delete middle of the cell' do
743
+ subject.delete_row(2)
744
+ expect(subject.merged_cells.size).to eq 1
745
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D3'
746
+ end
747
+
748
+ # | A1 | B1 | C1 | D1 | E1 |
749
+ # | A2 | MERGED | E2 |
750
+ # | A3 | | E3 |
751
+ # | A5 | B5 | C5 | D5 | E5 |
752
+ it 'should updates merged cell when delete bottom of the cell' do
753
+ subject.delete_row(3)
754
+ expect(subject.merged_cells.size).to eq 1
755
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D3'
756
+ end
757
+
758
+ # | A1 | B1 | C1 | D1 | E1 |
759
+ # | A2 | | E2 |
760
+ # | A3 | MERGED | E3 |
761
+ # | A4 | | E4 |
762
+ it 'should not updates merged cell when ldelete below the cell' do
763
+ subject.delete_row(4)
764
+ expect(subject.merged_cells.size).to eq 1
765
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D4'
766
+ end
767
+ end
768
+ end
769
+
770
+ it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
771
+ # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
772
+ subject.delete_row(0)
773
+ expect(subject.merged_cells).to be_nil
774
+ end
644
775
  end
645
776
 
646
777
  describe '.insert_row' do
647
778
  it 'should insert a row at index specified, "pushing" everything else "down"' do
648
- @worksheet.insert_row(0)
649
- expect(@worksheet[0][0]).to be_nil
650
- expect(@worksheet[1][0].value).to eq(@old_cell_value)
651
- expect(@worksheet[1][0].formula.expression.to_s).to eq(@old_cell_formula)
779
+ old_cell = subject[0][0]
780
+ old_cell_value = old_cell.value.to_s
781
+ old_cell_formula = old_cell.formula.expression.to_s
782
+
783
+ subject.insert_row(0)
784
+ expect(subject[0][0]).to be_nil
785
+ expect(subject[1][0].value).to eq(old_cell_value)
786
+ expect(subject[1][0].formula.expression.to_s).to eq(old_cell_formula)
652
787
 
653
- @worksheet.insert_row(5)
654
- expect(@worksheet[5][0].is_underlined).to be_nil
788
+ subject.insert_row(7)
789
+ expect(subject[7][0].is_underlined).to be_nil
655
790
  end
656
791
 
657
792
  it 'should insert a row skipping nil rows that might exist' do
658
- @worksheet.sheet_data.rows << nil << nil
659
- rows = @worksheet.sheet_data.rows.size
660
- @worksheet.insert_row(rows)
661
- expect(@worksheet[rows - 1]).to be_nil
793
+ subject.sheet_data.rows << nil << nil
794
+ rows = subject.sheet_data.rows.size
795
+ subject.insert_row(rows)
796
+ expect(subject[rows - 1]).to be_nil
662
797
  end
663
798
 
664
799
  it 'should insert a row at index specified, copying styles from row "above"' do
665
- @worksheet.change_row_font_name(0, 'Courier')
666
- @worksheet.insert_row(1)
667
- expect(@worksheet.get_row_font_name(1)).to eq('Courier')
800
+ subject.change_row_font_name(0, 'Courier')
801
+ subject.insert_row(1)
802
+ expect(subject.get_row_font_name(1)).to eq('Courier')
668
803
  end
669
804
 
670
805
  it 'should preserve (rather than fix) formulas that reference cells "pushed down" rows' do
671
- @worksheet.add_cell(5,0,nil, 'SUM(A1:A4)')
672
- @worksheet.insert_row(0)
673
- expect(@worksheet[6][0].formula.expression).to eq('SUM(A1:A4)')
806
+ subject.add_cell(5, 0, nil, 'SUM(A1:A4)')
807
+ subject.insert_row(0)
808
+ expect(subject[6][0].formula.expression).to eq('SUM(A1:A4)')
674
809
  end
675
810
 
676
811
  it 'should cause error if a negative argument is passed in' do
677
812
  expect {
678
- @worksheet.insert_row(-1)
813
+ subject.insert_row(-1)
679
814
  }.to raise_error(RuntimeError)
680
815
  end
681
816
 
682
- it 'should expand matrix to fit argument if nonnegative' do
683
- expect(@worksheet.sheet_data.size).to eq(11)
684
- @worksheet.insert_row(11)
685
- expect(@worksheet.sheet_data.size).to eq(13)
817
+ it 'should expand matrix to fit argument if nonnegative' do
818
+ expect(subject.sheet_data.size).to eq(11)
819
+ subject.insert_row(11)
820
+ expect(subject.sheet_data.size).to eq(13)
821
+ end
822
+
823
+ it 'should properly reindex the cells' do
824
+ subject.sheet_data.rows.each_with_index { |row, r|
825
+ if (SKIP_ROW_COL == r) then
826
+ expect(row).to be_nil
827
+ else
828
+ row.cells.each_with_index { |cell, c|
829
+ if (SKIP_ROW_COL == c) then
830
+ expect(cell).to be_nil
831
+ else
832
+ expect(cell.row).to eq(r)
833
+ expect(cell.column).to eq(c)
834
+ end
835
+ }
836
+ end
837
+ }
686
838
  end
687
839
 
688
- it 'should properly reindex the cells' do
689
- @worksheet.sheet_data.rows.each_with_index { |row, r|
690
- row.cells.each_with_index { |cell, c|
691
- expect(cell.row).to eq(r)
692
- expect(cell.column).to eq(c)
693
- }
694
- }
840
+ describe 'merged_cells updating' do
841
+ # | A1 | B1 | C1 | D1 |
842
+ # | A2 | MERGED | D2 |
843
+ # | A3 | | D3 |
844
+ # | A4 | B4 | C4 | D4 |
845
+ before do
846
+ subject.merge_cells(1, 1, 2, 2)
847
+ expect(subject.merged_cells.size).to eq 1
848
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C3'
849
+ end
850
+
851
+ # | A1 | B1 | C1 | D1 |
852
+ # | | | | |
853
+ # | A2 | MERGED | D2 |
854
+ # | A3 | | D3 |
855
+ # | A4 | B4 | C4 | D4 |
856
+ it 'should updates merged cell when insert above the cell' do
857
+ subject.insert_row(1)
858
+ expect(subject.merged_cells.size).to eq 1
859
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B3:C4'
860
+ end
861
+
862
+ # | A1 | B1 | C1 | D1 |
863
+ # | A2 | | D2 |
864
+ # | | MERGED | |
865
+ # | A3 | | D3 |
866
+ # | A4 | B4 | C4 | D4 |
867
+ it 'should updates merged cell when insert into the cell' do
868
+ subject.insert_row(2)
869
+ expect(subject.merged_cells.size).to eq 1
870
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C4'
871
+ end
872
+
873
+ # | A1 | B1 | C1 | D1 |
874
+ # | A2 | MERGED | D2 |
875
+ # | A3 | | D3 |
876
+ # | | | | |
877
+ # | A4 | B4 | C4 | D4 |
878
+ it 'should not updates merged cell when insert below the cell' do
879
+ subject.insert_row(3)
880
+ expect(subject.merged_cells.size).to eq 1
881
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C3'
882
+ end
883
+ end
884
+
885
+ it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
886
+ # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
887
+ subject.insert_row(0)
888
+ expect(subject.merged_cells).to be_nil
695
889
  end
696
890
  end
697
891
 
698
892
  describe '.delete_column' do
699
893
  it 'should delete a column at index specified, "pushing" everything else "left"' do
700
- @worksheet.delete_column(0)
701
- expect(@worksheet[0][0].value).to eq("0:1")
702
- expect(@worksheet[0][0].formula.expression.to_s).to eq("F0:1")
703
- expect(@worksheet[0][0].row).to eq(0)
894
+ subject.delete_column(0)
895
+ expect(subject[0][0].value).to eq('1:0')
896
+ expect(subject[0][0].formula.expression.to_s).to eq('F1:0')
897
+ expect(subject[0][0].row).to eq(0)
704
898
  end
705
899
 
706
900
  it 'should delete a column at index specified, "pushing" styles "left"' do
707
- @worksheet.change_column_font_name(1,"Courier")
708
- @worksheet.delete_column(0)
709
- expect(@worksheet.get_column_font_name(0)).to eq("Courier")
901
+ subject.change_column_font_name(1, 'Courier')
902
+ subject.delete_column(0)
903
+ expect(subject.get_column_font_name(0)).to eq('Courier')
710
904
  end
711
905
 
712
906
  it 'should preserve (rather than fix) formulas that reference cells in "pushed left" columns' do
713
- @worksheet.add_cell(0,4,nil, 'SUM(A1:D1)')
714
- @worksheet.delete_column(0)
715
- expect(@worksheet[0][3].formula.expression).to eq('SUM(A1:D1)')
907
+ subject.add_cell(0, 4, nil, 'SUM(A1:D1)')
908
+ subject.delete_column(0)
909
+ expect(subject[0][3].formula.expression).to eq('SUM(A1:D1)')
716
910
  end
717
911
 
718
912
  it 'should update cell indices after deleting the column' do
719
- @worksheet.delete_column(2)
720
- @worksheet[0].cells.each_with_index { |cell, i|
721
- expect(cell.column).to eq(i)
913
+ subject.delete_column(2)
914
+
915
+ subject.sheet_data.rows.each_with_index { |row, r|
916
+ if (SKIP_ROW_COL == r) then
917
+ expect(row).to be_nil
918
+ else
919
+ row.cells.each_with_index { |cell, c|
920
+ if (SKIP_ROW_COL - 1 == c) then
921
+ expect(cell).to be_nil
922
+ else
923
+ expect(cell.row).to eq(r)
924
+ expect(cell.column).to eq(c)
925
+ end
926
+ }
927
+ end
722
928
  }
723
929
  end
724
930
 
725
931
  it 'should cause error if negative argument is passed in' do
726
932
  expect {
727
- @worksheet.delete_column(-1)
933
+ subject.delete_column(-1)
728
934
  }.to raise_error(RuntimeError)
729
935
  end
730
936
 
731
- it 'should properly reindex the cells' do
732
- @worksheet.sheet_data.rows.each_with_index { |row, r|
733
- row.cells.each_with_index { |cell, c|
734
- expect(cell.row).to eq(r)
735
- expect(cell.column).to eq(c)
736
- }
937
+ it 'should properly reindex the cells' do
938
+ subject.sheet_data.rows.each_with_index { |row, r|
939
+ if (SKIP_ROW_COL == r) then
940
+ expect(row).to be_nil
941
+ else
942
+ row.cells.each_with_index { |cell, c|
943
+ if (SKIP_ROW_COL == c) then
944
+ expect(cell).to be_nil
945
+ else
946
+ expect(cell.row).to eq(r)
947
+ expect(cell.column).to eq(c)
948
+ end
949
+ }
950
+ end
737
951
  }
738
952
  end
953
+
954
+ describe 'merged_cells updating' do
955
+ context 'merged cells in the column' do
956
+ # | A1 | B1 | C1 |
957
+ # | A2 | | C2 |
958
+ # | A3 | MERGED | C3 |
959
+ # | A4 | | C4 |
960
+ # | A5 | B5 | C5 |
961
+ before do
962
+ subject.merge_cells(1, 1, 3, 1)
963
+ expect(subject.merged_cells.size).to eq 1
964
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:B4'
965
+ end
966
+ it 'should delete merged cell' do
967
+ subject.delete_column(1)
968
+ expect(subject.merged_cells.size).to eq 0
969
+ end
970
+ end
971
+ context 'merged horizontal two cells' do
972
+ # | A1 | B1 | C1 | D1 |
973
+ # | A2 | MERGED | D2 |
974
+ # | A3 | B3 | C3 | D3 |
975
+ before do
976
+ subject.merge_cells(1, 1, 1, 2)
977
+ expect(subject.merged_cells.size).to eq 1
978
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C2'
979
+ end
980
+ it 'should delete merged cell' do
981
+ subject.delete_column(1)
982
+ expect(subject.merged_cells.size).to eq 0
983
+ end
984
+ end
985
+ context 'merged three or more columns' do
986
+ # | A1 | B1 | C1 | D1 | E1 |
987
+ # | A2 | | E2 |
988
+ # | A3 | MERGED | E3 |
989
+ # | A4 | | E4 |
990
+ # | A5 | B5 | C5 | D5 | E5 |
991
+ before do
992
+ subject.merge_cells(1, 1, 3, 3)
993
+ expect(subject.merged_cells.size).to eq 1
994
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D4'
995
+ end
996
+ # | B1 | C1 | D1 | E1 |
997
+ # | | E2 |
998
+ # | MERGED | E3 |
999
+ # | | E4 |
1000
+ # | B5 | C5 | D5 | E5 |
1001
+ it 'should updates merged cell when delete before the cell' do
1002
+ subject.delete_column(0)
1003
+ expect(subject.merged_cells.size).to eq 1
1004
+ expect(subject.merged_cells.first.ref.to_s).to eq 'A2:C4'
1005
+ end
1006
+ # | A1 | C1 | D1 | E1 |
1007
+ # | A2 | | E2 |
1008
+ # | A3 | MERGED | E3 |
1009
+ # | A4 | | E4 |
1010
+ # | A5 | C5 | D5 | E5 |
1011
+ it 'should updates merged cell when delete left of the cell' do
1012
+ subject.delete_column(1)
1013
+ expect(subject.merged_cells.size).to eq 1
1014
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C4'
1015
+ end
1016
+ # | A1 | B1 | D1 | E1 |
1017
+ # | A2 | | E2 |
1018
+ # | A3 | MERGED | E3 |
1019
+ # | A4 | | E4 |
1020
+ # | A5 | B5 | D5 | E5 |
1021
+ it 'should updates merged cell when delete center of the cell' do
1022
+ subject.delete_column(2)
1023
+ expect(subject.merged_cells.size).to eq 1
1024
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C4'
1025
+ end
1026
+ # | A1 | B1 | C1 | E1 |
1027
+ # | A2 | | E2 |
1028
+ # | A3 | MERGED | E3 |
1029
+ # | A4 | | E4 |
1030
+ # | A5 | B5 | C5 | E5 |
1031
+ it 'should updates merged cell when delete right of the cell' do
1032
+ subject.delete_column(3)
1033
+ expect(subject.merged_cells.size).to eq 1
1034
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C4'
1035
+ end
1036
+ # | A1 | B1 | C1 | D1 |
1037
+ # | A2 | |
1038
+ # | A3 | MERGED |
1039
+ # | A4 | |
1040
+ # | A5 | B5 | C5 | D5 |
1041
+ it 'should not updates merged cell when delete after the cell' do
1042
+ subject.delete_column(4)
1043
+ expect(subject.merged_cells.size).to eq 1
1044
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D4'
1045
+ end
1046
+ end
1047
+ end
1048
+
1049
+ it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
1050
+ # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
1051
+ subject.delete_column(0)
1052
+ expect(subject.merged_cells).to be_nil
1053
+ end
739
1054
  end
740
1055
 
741
1056
  describe '.insert_column' do
742
1057
  it 'should insert a column at index specified, "pushing" everything else "right"' do
743
- @worksheet.insert_column(0)
744
- expect(@worksheet[0][0]).to be_nil
745
- expect(@worksheet[0][1].value).to eq(@old_cell_value)
746
- expect(@worksheet[0][1].formula.expression.to_s).to eq(@old_cell_formula)
1058
+ old_cell = subject[0][0]
1059
+ old_cell_value = old_cell.value.to_s
1060
+ old_cell_formula = old_cell.formula.expression.to_s
1061
+
1062
+ subject.insert_column(0)
1063
+ expect(subject[0][0]).to be_nil
1064
+ expect(subject[0][1].value).to eq(old_cell_value)
1065
+ expect(subject[0][1].formula.expression.to_s).to eq(old_cell_formula)
747
1066
  end
748
1067
 
749
1068
  it 'should insert a column at index specified, copying styles from column to "left"' do
750
- @worksheet.change_column_font_name(0, 'Courier')
751
- @worksheet.insert_column(1)
752
- expect(@worksheet.get_column_font_name(1)).to eq('Courier')
1069
+ subject.change_column_font_name(0, 'Courier')
1070
+ subject.insert_column(1)
1071
+ expect(subject.get_column_font_name(1)).to eq('Courier')
753
1072
  end
754
1073
 
755
1074
  it 'should insert a column at 0 without copying any styles, when passed 0 as column index' do
756
- @worksheet.change_column_font_name(0, 'Courier')
757
- @worksheet.insert_column(0)
758
- expect(@worksheet.get_column_font_name(0)).to eq('Verdana') #not courier
1075
+ subject.change_column_font_name(0, 'Courier')
1076
+ subject.insert_column(0)
1077
+ expect(subject.get_column_font_name(0)).to eq('Verdana') # not courier
759
1078
  end
760
1079
 
761
1080
  it 'should preserve (rather than fix) formulas that reference cells in "pushed right" column' do
762
- @worksheet.add_cell(0,5,nil, 'SUM(A1:D1)')
763
- @worksheet.insert_column(0)
764
- expect(@worksheet[0][6].formula.expression).to eq('SUM(A1:D1)')
1081
+ subject.add_cell(0, 5, nil, 'SUM(A1:D1)')
1082
+ subject.insert_column(0)
1083
+ expect(subject[0][6].formula.expression).to eq('SUM(A1:D1)')
765
1084
  end
766
1085
 
767
1086
  it 'should update cell indices after deleting the column' do
768
- @worksheet.insert_column(5)
769
- @worksheet[0].cells.each_with_index { |cell, i|
1087
+ subject.insert_column(5)
1088
+ subject[0].cells.each_with_index { |cell, i|
770
1089
  next if cell.nil?
771
1090
  expect(cell.column).to eq(i)
772
1091
  }
@@ -774,590 +1093,665 @@ describe RubyXL::Worksheet do
774
1093
 
775
1094
  it 'should cause error if a negative argument is passed in' do
776
1095
  expect {
777
- @worksheet.insert_column(-1)
1096
+ subject.insert_column(-1)
778
1097
  }.to raise_error(RuntimeError)
779
1098
  end
780
1099
 
781
- it 'should properly reindex the cells' do
782
- @worksheet.sheet_data.rows.each_with_index { |row, r|
783
- row.cells.each_with_index { |cell, c|
784
- expect(cell.row).to eq(r)
785
- expect(cell.column).to eq(c)
786
- }
1100
+ it 'should properly reindex the cells' do
1101
+ subject.sheet_data.rows.each_with_index { |row, r|
1102
+ if (SKIP_ROW_COL == r) then
1103
+ expect(row).to be_nil
1104
+ else
1105
+ row.cells.each_with_index { |cell, c|
1106
+ if (SKIP_ROW_COL == c) then
1107
+ expect(cell).to be_nil
1108
+ else
1109
+ expect(cell.row).to eq(r)
1110
+ expect(cell.column).to eq(c)
1111
+ end
1112
+ }
1113
+ end
787
1114
  }
788
1115
  end
1116
+
1117
+ describe 'merged_cells updating' do
1118
+ # | A1 | B1 | C1 | D1 |
1119
+ # | A2 | MERGED | D2 |
1120
+ # | A3 | | D3 |
1121
+ # | A4 | B4 | C4 | D4 |
1122
+ before do
1123
+ subject.merge_cells(1, 1, 2, 2)
1124
+ expect(subject.merged_cells.size).to eq 1
1125
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C3'
1126
+ end
1127
+
1128
+ # | A1 | | B1 | C1 | D1 |
1129
+ # | A2 | | MERGED | D2 |
1130
+ # | A3 | | | D3 |
1131
+ # | A4 | | B4 | C4 | D4 |
1132
+ it 'should updates merged cell when insert before the cell' do
1133
+ subject.insert_column(1)
1134
+ expect(subject.merged_cells.size).to eq 1
1135
+ expect(subject.merged_cells.first.ref.to_s).to eq 'C2:D3'
1136
+ end
1137
+
1138
+ # | A1 | B1 | | C1 | D1 |
1139
+ # | A2 | MERGED | D2 |
1140
+ # | A3 | | D3 |
1141
+ # | A4 | B4 | | C4 | D4 |
1142
+ it 'should updates merged cell when insert into the cell' do
1143
+ subject.insert_column(2)
1144
+ expect(subject.merged_cells.size).to eq 1
1145
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:D3'
1146
+ end
1147
+
1148
+ # | A1 | B1 | C1 | | D1 |
1149
+ # | A2 | MERGED | | D2 |
1150
+ # | A3 | | | D3 |
1151
+ # | A4 | B4 | C4 | | D4 |
1152
+ it 'should not updates merged cell when insert after the cell' do
1153
+ subject.insert_column(3)
1154
+ expect(subject.merged_cells.size).to eq 1
1155
+ expect(subject.merged_cells.first.ref.to_s).to eq 'B2:C3'
1156
+ end
1157
+ end
1158
+
1159
+ it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
1160
+ # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
1161
+ subject.insert_column(0)
1162
+ expect(subject.merged_cells).to be_nil
1163
+ end
789
1164
  end
790
1165
 
791
1166
  describe '.insert_cell' do
792
1167
  it 'should simply add a cell if no shift argument is specified' do
793
- @worksheet.insert_cell(0,0, 'test')
794
- expect(@worksheet[0][0].value).to eq('test')
795
- expect(@worksheet[0][1].value).to eq('0:1')
796
- expect(@worksheet[1][0].value).to eq('1:0')
1168
+ subject.insert_cell(0, 0, 'test')
1169
+ expect(subject[0][0].value).to eq('test')
1170
+ expect(subject[0][1].value).to eq('1:0')
1171
+ expect(subject[1][0].value).to eq('0:1')
797
1172
  end
798
1173
 
799
1174
  it 'should shift cells to the right if :right is specified' do
800
- @worksheet.insert_cell(0, 0, 'test', nil, :right)
801
- expect(@worksheet[0][0].value).to eq('test')
802
- expect(@worksheet[0][1].value).to eq('0:0')
803
- expect(@worksheet[1][0].value).to eq('1:0')
1175
+ subject.insert_cell(0, 0, 'test', nil, :right)
1176
+ expect(subject[0][0].value).to eq('test')
1177
+ expect(subject[0][1].value).to eq('0:0')
1178
+ expect(subject[1][0].value).to eq('0:1')
804
1179
  end
805
1180
 
806
1181
  it 'should update cell indices after inserting the cell' do
807
- @worksheet.insert_cell(0, 0, 'test', nil, :right)
808
- @worksheet[0].cells.each_with_index { |cell, i|
809
- expect(cell.column).to eq(i)
1182
+ subject.insert_cell(0, 0, 'test', nil, :right)
1183
+ subject.sheet_data.rows.each_with_index { |row, r|
1184
+ if (SKIP_ROW_COL == r) then
1185
+ expect(row).to be_nil
1186
+ else
1187
+ row.cells.each_with_index { |cell, c|
1188
+ if ((r == 0) && (SKIP_ROW_COL + 1 == c)) || ((r != 0) && (SKIP_ROW_COL == c)) then
1189
+ expect(cell).to be_nil
1190
+ else
1191
+ expect(cell.row).to eq(r)
1192
+ expect(cell.column).to eq(c)
1193
+ end
1194
+ }
1195
+ end
810
1196
  }
811
1197
  end
812
1198
 
813
1199
  it 'should shift cells down if :down is specified' do
814
- @worksheet.insert_cell(0, 0, 'test', nil, :down)
815
- expect(@worksheet[0][0].value).to eq('test')
816
- expect(@worksheet[0][1].value).to eq('0:1')
817
- expect(@worksheet[1][0].value).to eq('0:0')
1200
+ subject.insert_cell(0, 0, 'test', nil, :down)
1201
+ expect(subject[0][0].value).to eq('test')
1202
+ expect(subject[0][1].value).to eq('1:0')
1203
+ expect(subject[1][0].value).to eq('0:0')
818
1204
  end
819
1205
 
820
1206
  it 'should cause error if shift argument is specified whcih is not :right or :down' do
821
1207
  expect {
822
- @worksheet.insert_cell(0, 0, 'test', nil, :up)
1208
+ subject.insert_cell(0, 0, 'test', nil, :up)
823
1209
  }.to raise_error(RuntimeError)
824
1210
  end
825
1211
 
826
1212
  it 'should cause error if a negative argument is passed in' do
827
1213
  expect {
828
- @worksheet.insert_cell(-1, -1)
1214
+ subject.insert_cell(-1, -1)
829
1215
  }.to raise_error(RuntimeError)
830
1216
  end
831
1217
  end
832
1218
 
833
1219
  describe '.delete_cell' do
834
1220
  it 'should make a cell nil if no shift argument specified' do
835
- deleted = @worksheet.delete_cell(0, 0)
836
- expect(@worksheet[0][0]).to be_nil
837
- expect(@old_cell.inspect).to eq(deleted.inspect)
1221
+ old_cell = subject[0][0].inspect
1222
+
1223
+ deleted = subject.delete_cell(0, 0)
1224
+ expect(subject[0][0]).to be_nil
1225
+ expect(old_cell).to eq(deleted.inspect)
838
1226
  end
839
1227
 
840
1228
  it 'should return nil if a cell which is out of range is specified' do
841
- expect(@worksheet.delete_cell(12, 12)).to be_nil
1229
+ expect(subject.delete_cell(12, 12)).to be_nil
842
1230
  end
843
1231
 
844
1232
  it 'should cause error if a negative argument is passed in' do
845
1233
  expect {
846
- @worksheet.delete_cell(-1,-1)
1234
+ subject.delete_cell(-1, -1)
847
1235
  }.to raise_error(RuntimeError)
848
1236
  end
849
1237
 
850
1238
  it 'should shift cells to the right of the deleted cell left if :left is specified' do
851
- @worksheet.delete_cell(0, 0, :left)
852
- expect(@worksheet[0][0].value).to eq('0:1')
1239
+ subject.delete_cell(0, 0, :left)
1240
+ expect(subject[0][0].value).to eq('1:0')
853
1241
  end
854
1242
 
855
1243
  it 'should update cell indices after deleting the cell' do
856
- @worksheet.delete_cell(4, 0, :left)
857
- @worksheet[0].cells.each_with_index { |cell, i|
858
- expect(cell.column).to eq(i)
1244
+ subject.delete_cell(4, 0, :left)
1245
+ subject[0].cells.each_with_index { |cell, i|
1246
+ if SKIP_ROW_COL == i then
1247
+ expect(cell).to be_nil
1248
+ else
1249
+ expect(cell.column).to eq(i)
1250
+ end
859
1251
  }
860
1252
  end
861
1253
 
862
1254
  it 'should shift cells below the deleted cell up if :up is specified' do
863
- @worksheet.delete_cell(0,0,:up)
864
- expect(@worksheet[0][0].value).to eq('1:0')
1255
+ subject.delete_cell(0, 0, :up)
1256
+ expect(subject[0][0].value).to eq('0:1')
865
1257
  end
866
1258
 
867
1259
  it 'should cause en error if an argument other than :left, :up, or nil is specified for shift' do
868
1260
  expect {
869
- @worksheet.delete_cell(0,0,:down)
1261
+ subject.delete_cell(0, 0, :down)
870
1262
  }.to raise_error(RuntimeError)
871
1263
  end
872
1264
  end
873
1265
 
874
1266
  describe '.get_row_fill' do
875
1267
  it 'should return white (ffffff) if no fill color specified for row' do
876
- expect(@worksheet.get_row_fill(0)).to eq('ffffff')
1268
+ expect(subject.get_row_fill(0)).to eq('ffffff')
877
1269
  end
878
1270
 
879
1271
  it 'should correctly reflect fill color if specified for row' do
880
- @worksheet.change_row_fill(0, '000000')
881
- expect(@worksheet.get_row_fill(0)).to eq('000000')
1272
+ subject.change_row_fill(0, '000000')
1273
+ expect(subject.get_row_fill(0)).to eq('000000')
882
1274
  end
883
1275
 
884
1276
  it 'should return nil if a row which does not exist is passed in' do
885
- expect(@worksheet.get_row_fill(11)).to be_nil
1277
+ expect(subject.get_row_fill(11)).to be_nil
886
1278
  end
887
1279
  end
888
1280
 
889
1281
  describe '.get_row_font_name' do
890
1282
  it 'should correctly reflect font name for row' do
891
- @worksheet.change_row_font_name(0, 'Courier')
892
- expect(@worksheet.get_row_font_name(0)).to eq('Courier')
1283
+ subject.change_row_font_name(0, 'Courier')
1284
+ expect(subject.get_row_font_name(0)).to eq('Courier')
893
1285
  end
894
1286
 
895
1287
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
896
- expect(@worksheet.get_row_font_name(11)).to be_nil
1288
+ expect(subject.get_row_font_name(11)).to be_nil
897
1289
  end
898
1290
  end
899
1291
 
900
1292
  describe '.get_row_font_size' do
901
1293
  it 'should correctly reflect font size for row' do
902
- @worksheet.change_row_font_size(0,30)
903
- expect(@worksheet.get_row_font_size(0)).to eq(30)
1294
+ subject.change_row_font_size(0, 30)
1295
+ expect(subject.get_row_font_size(0)).to eq(30)
904
1296
  end
905
1297
 
906
1298
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
907
- expect(@worksheet.get_row_font_size(11)).to be_nil
1299
+ expect(subject.get_row_font_size(11)).to be_nil
908
1300
  end
909
1301
  end
910
1302
 
911
1303
  describe '.get_row_font_color' do
912
1304
  it 'should correctly reflect font color for row' do
913
- @worksheet.change_row_font_color(0, '0f0f0f')
914
- expect(@worksheet.get_row_font_color(0)).to eq('0f0f0f')
1305
+ subject.change_row_font_color(0, '0f0f0f')
1306
+ expect(subject.get_row_font_color(0)).to eq('0f0f0f')
915
1307
  end
916
1308
 
917
1309
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
918
- expect(@worksheet.get_row_font_color(11)).to be_nil
1310
+ expect(subject.get_row_font_color(11)).to be_nil
919
1311
  end
920
1312
  end
921
1313
 
922
1314
  describe '.is_row_italicized' do
923
1315
  it 'should correctly return whether row is italicized' do
924
- @worksheet.change_row_italics(0, true)
925
- expect(@worksheet.is_row_italicized(0)).to eq(true)
1316
+ subject.change_row_italics(0, true)
1317
+ expect(subject.is_row_italicized(0)).to eq(true)
926
1318
  end
927
1319
 
928
1320
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
929
- expect(@worksheet.is_row_italicized(11)).to be_nil
1321
+ expect(subject.is_row_italicized(11)).to be_nil
930
1322
  end
931
1323
  end
932
1324
 
933
1325
  describe '.is_row_bolded' do
934
1326
  it 'should correctly return whether row is bolded' do
935
- @worksheet.change_row_bold(0, true)
936
- expect(@worksheet.is_row_bolded(0)).to eq(true)
1327
+ subject.change_row_bold(0, true)
1328
+ expect(subject.is_row_bolded(0)).to eq(true)
937
1329
  end
938
1330
 
939
1331
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
940
- expect(@worksheet.is_row_bolded(11)).to be_nil
1332
+ expect(subject.is_row_bolded(11)).to be_nil
941
1333
  end
942
1334
  end
943
1335
 
944
1336
  describe '.is_row_underlined' do
945
1337
  it 'should correctly return whether row is underlined' do
946
- @worksheet.change_row_underline(0, true)
947
- expect(@worksheet.is_row_underlined(0)).to eq(true)
1338
+ subject.change_row_underline(0, true)
1339
+ expect(subject.is_row_underlined(0)).to eq(true)
948
1340
  end
949
1341
 
950
1342
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
951
- expect(@worksheet.is_row_underlined(11)).to be_nil
1343
+ expect(subject.is_row_underlined(11)).to be_nil
952
1344
  end
953
1345
  end
954
1346
 
955
1347
  describe '.is_row_struckthrough' do
956
1348
  it 'should correctly return whether row is struckthrough' do
957
- @worksheet.change_row_strikethrough(0, true)
958
- expect(@worksheet.is_row_struckthrough(0)).to eq(true)
1349
+ subject.change_row_strikethrough(0, true)
1350
+ expect(subject.is_row_struckthrough(0)).to eq(true)
959
1351
  end
960
1352
 
961
1353
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
962
- expect(@worksheet.is_row_struckthrough(11)).to be_nil
1354
+ expect(subject.is_row_struckthrough(11)).to be_nil
963
1355
  end
964
1356
  end
965
1357
 
966
1358
  describe '.get_row_height' do
967
1359
  it 'should return 13 if no height specified for row' do
968
- expect(@worksheet.get_row_height(0)).to eq(13)
1360
+ expect(subject.get_row_height(0)).to eq(13)
969
1361
  end
970
1362
 
971
1363
  it 'should correctly reflect height if specified for row' do
972
- @worksheet.change_row_height(0, 30)
973
- expect(@worksheet.get_row_height(0)).to eq(30)
1364
+ subject.change_row_height(0, 30)
1365
+ expect(subject.get_row_height(0)).to eq(30)
974
1366
  end
975
1367
 
976
1368
  it 'should return default row height if a row which does not exist is passed in' do
977
- expect(@worksheet.get_row_height(11)).to eq(13)
1369
+ expect(subject.get_row_height(11)).to eq(13)
978
1370
  end
979
1371
 
980
1372
  it 'should cause error if a negative argument is passed in' do
981
1373
  expect {
982
- @worksheet.get_row_height(-1)
1374
+ subject.get_row_height(-1)
983
1375
  }.to raise_error(RuntimeError)
984
1376
  end
985
1377
  end
986
1378
 
987
1379
  describe '.get_row_alignment' do
988
- it 'should cause error if a negative argument is passed in' do
989
- expect {
990
- @worksheet.get_row_alignment(-1, true)
991
- }.to raise_error(RuntimeError)
992
- end
993
-
994
1380
  it 'should return nil if no horizontal alignment specified for row' do
995
- expect(@worksheet.get_row_alignment(0, true)).to be_nil
1381
+ expect(subject.get_row_alignment(0, true)).to be_nil
996
1382
  end
997
1383
 
998
1384
  it 'should return nil if a row which does not exist is passed in' do
999
- expect(@worksheet.get_row_alignment(11, true)).to be_nil
1385
+ expect(subject.get_row_alignment(11, true)).to be_nil
1000
1386
  end
1001
1387
 
1002
1388
  it 'should return correct horizontal alignment if it is set for that row' do
1003
- @worksheet.change_row_horizontal_alignment(0, 'center')
1004
- expect(@worksheet.get_row_alignment(0, true)).to eq('center')
1389
+ subject.change_row_horizontal_alignment(0, 'center')
1390
+ expect(subject.get_row_alignment(0, true)).to eq('center')
1005
1391
  end
1006
1392
 
1007
1393
  it 'should return nil if no alignment specified for row' do
1008
- expect(@worksheet.get_row_alignment(0, false)).to be_nil
1394
+ expect(subject.get_row_alignment(0, false)).to be_nil
1009
1395
  end
1010
1396
 
1011
1397
  it 'should return nil if a row which does not exist is passed in' do
1012
- expect(@worksheet.get_row_alignment(11, false)).to be_nil
1398
+ expect(subject.get_row_alignment(11, false)).to be_nil
1013
1399
  end
1014
1400
 
1015
1401
  it 'should return correct vertical alignment if it is set for that row' do
1016
- @worksheet.change_row_vertical_alignment(0, 'center')
1017
- expect(@worksheet.get_row_alignment(0, false)).to eq('center')
1402
+ subject.change_row_vertical_alignment(0, 'center')
1403
+ expect(subject.get_row_alignment(0, false)).to eq('center')
1018
1404
  end
1019
1405
  end
1020
1406
 
1021
1407
  describe '.get_row_border' do
1022
1408
  it 'should return nil if no border is specified for that row in that direction' do
1023
- expect(@worksheet.get_row_border(0, :top)).to be_nil
1409
+ expect(subject.get_row_border(0, :top)).to be_nil
1024
1410
  end
1025
1411
 
1026
1412
  it 'should return type of border that this row has on top' do
1027
- @worksheet.change_row_border(0, :top, 'thin')
1028
- expect(@worksheet.get_row_border(0, :top)).to eq('thin')
1029
- end
1030
-
1031
- it 'should cause error if a negative argument is passed in' do
1032
- expect {
1033
- @worksheet.get_row_border(-1, :top)
1034
- }.to raise_error(RuntimeError)
1413
+ subject.change_row_border(0, :top, 'thin')
1414
+ expect(subject.get_row_border(0, :top)).to eq('thin')
1035
1415
  end
1036
1416
 
1037
1417
  it 'should return nil if a row which does not exist is passed in' do
1038
- expect(@worksheet.get_row_border(11, :top)).to be_nil
1418
+ expect(subject.get_row_border(11, :top)).to be_nil
1039
1419
  end
1040
1420
  end
1041
1421
 
1042
1422
  describe '.get_column_font_name' do
1043
1423
  it 'should correctly reflect font name for column' do
1044
- @worksheet.change_column_font_name(0, 'Courier')
1045
- expect(@worksheet.get_column_font_name(0)).to eq('Courier')
1424
+ subject.change_column_font_name(0, 'Courier')
1425
+ expect(subject.get_column_font_name(0)).to eq('Courier')
1046
1426
  end
1047
1427
 
1048
1428
  it 'should cause error if a negative argument is passed in' do
1049
1429
  expect {
1050
- @worksheet.get_column_font_name(-1)
1430
+ subject.get_column_font_name(-1)
1051
1431
  }.to raise_error(RuntimeError)
1052
1432
  end
1053
1433
 
1054
1434
  it 'should return default font if a (nonnegative) column which does not exist is passed in' do
1055
- expect(@worksheet.get_column_font_name(11)).to eq('Verdana')
1435
+ expect(subject.get_column_font_name(11)).to eq('Verdana')
1056
1436
  end
1057
1437
  end
1058
1438
 
1059
1439
  describe '.get_column_font_size' do
1060
1440
  it 'should correctly reflect font size for column' do
1061
- @worksheet.change_column_font_size(0,30)
1062
- expect(@worksheet.get_column_font_size(0)).to eq(30)
1441
+ subject.change_column_font_size(0, 30)
1442
+ expect(subject.get_column_font_size(0)).to eq(30)
1063
1443
  end
1064
1444
 
1065
1445
  it 'should cause error if a negative argument is passed in' do
1066
1446
  expect {
1067
- @worksheet.get_column_font_size(-1)
1447
+ subject.get_column_font_size(-1)
1068
1448
  }.to raise_error(RuntimeError)
1069
1449
  end
1070
1450
 
1071
1451
  it 'should return default font size if a column which does not exist is passed in' do
1072
- expect(@worksheet.get_column_font_size(11)).to eq(10)
1452
+ expect(subject.get_column_font_size(11)).to eq(10)
1073
1453
  end
1074
1454
  end
1075
1455
 
1076
1456
  describe '.get_column_font_color' do
1077
1457
  it 'should correctly reflect font color for column' do
1078
- @worksheet.change_column_font_color(0, '0f0f0f')
1079
- expect(@worksheet.get_column_font_color(0)).to eq('0f0f0f')
1458
+ subject.change_column_font_color(0, '0f0f0f')
1459
+ expect(subject.get_column_font_color(0)).to eq('0f0f0f')
1080
1460
  end
1081
1461
 
1082
1462
  it 'should cause error if a negative argument is passed in' do
1083
1463
  expect {
1084
- @worksheet.get_column_font_color(-1)
1464
+ subject.get_column_font_color(-1)
1085
1465
  }.to raise_error(RuntimeError)
1086
1466
  end
1087
1467
 
1088
1468
  it 'should return default color (000000) if a (nonnegative) column which does not exist is passed in' do
1089
- expect(@worksheet.get_column_font_color(11)).to eq('000000')
1469
+ expect(subject.get_column_font_color(11)).to eq('000000')
1090
1470
  end
1091
1471
 
1092
1472
  it 'should return default color (000000) if no rgb font color is specified' do
1093
- expect(@worksheet.get_column_font_color(0)).to eq('000000')
1473
+ expect(subject.get_column_font_color(0)).to eq('000000')
1094
1474
  end
1095
1475
  end
1096
1476
 
1097
1477
  describe '.is_column_italicized' do
1098
1478
  it 'should correctly return whether column is italicized' do
1099
- @worksheet.change_column_italics(0, true)
1100
- expect(@worksheet.is_column_italicized(0)).to eq(true)
1479
+ subject.change_column_italics(0, true)
1480
+ expect(subject.is_column_italicized(0)).to eq(true)
1101
1481
  end
1102
1482
 
1103
1483
  it 'should cause error if a negative argument is passed in' do
1104
1484
  expect {
1105
- @worksheet.is_column_italicized(-1)
1485
+ subject.is_column_italicized(-1)
1106
1486
  }.to raise_error(RuntimeError)
1107
1487
  end
1108
1488
 
1109
1489
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1110
- expect(@worksheet.is_column_italicized(11)).to be_nil
1490
+ expect(subject.is_column_italicized(11)).to be_nil
1111
1491
  end
1112
1492
  end
1113
1493
 
1114
1494
  describe '.is_column_bolded' do
1115
1495
  it 'should correctly return whether column is bolded' do
1116
- @worksheet.change_column_bold(0, true)
1117
- expect(@worksheet.is_column_bolded(0)).to eq(true)
1496
+ subject.change_column_bold(0, true)
1497
+ expect(subject.is_column_bolded(0)).to eq(true)
1118
1498
  end
1119
1499
 
1120
1500
  it 'should cause error if a negative argument is passed in' do
1121
1501
  expect {
1122
- @worksheet.is_column_bolded(-1)
1502
+ subject.is_column_bolded(-1)
1123
1503
  }.to raise_error(RuntimeError)
1124
1504
  end
1125
1505
 
1126
1506
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1127
- expect(@worksheet.is_column_bolded(11)).to be_nil
1507
+ expect(subject.is_column_bolded(11)).to be_nil
1128
1508
  end
1129
1509
  end
1130
1510
 
1131
1511
  describe '.is_column_underlined' do
1132
1512
  it 'should correctly return whether column is underlined' do
1133
- @worksheet.change_column_underline(0, true)
1134
- expect(@worksheet.is_column_underlined(0)).to eq(true)
1513
+ subject.change_column_underline(0, true)
1514
+ expect(subject.is_column_underlined(0)).to eq(true)
1135
1515
  end
1136
1516
 
1137
1517
  it 'should cause error if a negative argument is passed in' do
1138
1518
  expect {
1139
- @worksheet.is_column_underlined(-1)
1519
+ subject.is_column_underlined(-1)
1140
1520
  }.to raise_error(RuntimeError)
1141
1521
  end
1142
1522
 
1143
1523
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1144
- expect(@worksheet.is_column_underlined(11)).to be_nil
1524
+ expect(subject.is_column_underlined(11)).to be_nil
1145
1525
  end
1146
1526
  end
1147
1527
 
1148
1528
  describe '.is_column_struckthrough' do
1149
1529
  it 'should correctly return whether column is struckthrough' do
1150
- @worksheet.change_column_strikethrough(0, true)
1151
- expect(@worksheet.is_column_struckthrough(0)).to eq(true)
1530
+ subject.change_column_strikethrough(0, true)
1531
+ expect(subject.is_column_struckthrough(0)).to eq(true)
1152
1532
  end
1153
1533
 
1154
1534
  it 'should cause error if a negative argument is passed in' do
1155
1535
  expect {
1156
- @worksheet.is_column_struckthrough(-1)
1536
+ subject.is_column_struckthrough(-1)
1157
1537
  }.to raise_error(RuntimeError)
1158
1538
  end
1159
1539
 
1160
1540
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1161
- expect(@worksheet.is_column_struckthrough(11)).to be_nil
1541
+ expect(subject.is_column_struckthrough(11)).to be_nil
1162
1542
  end
1163
1543
  end
1164
1544
 
1165
1545
  describe '.get_column_width_raw' do
1166
1546
  it 'should return nil if no width specified for column' do
1167
- expect(@worksheet.get_column_width_raw(0)).to be_nil
1547
+ expect(subject.get_column_width_raw(0)).to be_nil
1168
1548
  end
1169
1549
 
1170
1550
  it 'should correctly reflect width if specified for column' do
1171
- @worksheet.change_column_width_raw(0, 30.123)
1172
- expect(@worksheet.get_column_width_raw(0)).to eq(30.123)
1551
+ subject.change_column_width_raw(0, 30.123)
1552
+ expect(subject.get_column_width_raw(0)).to eq(30.123)
1173
1553
  end
1174
1554
 
1175
1555
  it 'should return nil for a column that does not exist' do
1176
- expect(@worksheet.get_column_width_raw(11)).to be_nil
1556
+ expect(subject.get_column_width_raw(11)).to be_nil
1177
1557
  end
1178
1558
 
1179
1559
  it 'should cause error if a negative argument is passed in' do
1180
1560
  expect {
1181
- @worksheet.get_column_width_raw(-1)
1561
+ subject.get_column_width_raw(-1)
1182
1562
  }.to raise_error(RuntimeError)
1183
1563
  end
1184
1564
  end
1185
1565
 
1186
1566
  describe '.get_column_width' do
1187
1567
  it 'should return default width if no width specified for column' do
1188
- expect(@worksheet.get_column_width(0)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
1568
+ expect(subject.get_column_width(0)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
1189
1569
  end
1190
1570
 
1191
1571
  it 'should correctly reflect width if specified for column' do
1192
- @worksheet.change_column_width(0, 15)
1193
- expect(@worksheet.get_column_width(0)).to eq(15)
1572
+ subject.change_column_width(0, 15)
1573
+ expect(subject.get_column_width(0)).to eq(15)
1194
1574
  end
1195
1575
 
1196
1576
  it 'should return default width for a column that does not exist' do
1197
- expect(@worksheet.get_column_width(11)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
1577
+ expect(subject.get_column_width(11)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
1198
1578
  end
1199
1579
 
1200
1580
  it 'should cause error if a negative argument is passed in' do
1201
1581
  expect {
1202
- @worksheet.get_column_width(-1)
1582
+ subject.get_column_width(-1)
1203
1583
  }.to raise_error(RuntimeError)
1204
1584
  end
1205
1585
  end
1206
1586
 
1207
1587
  describe '.get_column_fill' do
1208
1588
  it 'should return white (ffffff) if no fill color specified for column' do
1209
- expect(@worksheet.get_column_fill(0)).to eq('ffffff')
1589
+ expect(subject.get_column_fill(0)).to eq('ffffff')
1210
1590
  end
1211
1591
 
1212
1592
  it 'should correctly reflect fill color if specified for column' do
1213
- @worksheet.change_column_fill(0, '000000')
1214
- expect(@worksheet.get_column_fill(0)).to eq('000000')
1593
+ subject.change_column_fill(0, '000000')
1594
+ expect(subject.get_column_fill(0)).to eq('000000')
1215
1595
  end
1216
1596
 
1217
1597
  it 'should return nil if a column which does not exist is passed in' do
1218
- expect(@worksheet.get_column_fill(11)).to eq('ffffff')
1598
+ expect(subject.get_column_fill(11)).to eq('ffffff')
1219
1599
  end
1220
1600
 
1221
1601
  it 'should cause error if a negative argument is passed in' do
1222
1602
  expect {
1223
- @worksheet.get_column_fill(-1)
1603
+ subject.get_column_fill(-1)
1224
1604
  }.to raise_error(RuntimeError)
1225
1605
  end
1226
1606
  end
1227
1607
 
1228
1608
  describe '.get_column_horizontal_alignment' do
1229
1609
  it 'should return nil if no alignment specified for column' do
1230
- expect(@worksheet.get_column_alignment(0, :horizontal)).to be_nil
1610
+ expect(subject.get_column_alignment(0, :horizontal)).to be_nil
1231
1611
  end
1232
1612
 
1233
1613
  it 'should return nil if a column which does not exist is passed in' do
1234
- expect(@worksheet.get_column_alignment(11, :horizontal)).to be_nil
1614
+ expect(subject.get_column_alignment(11, :horizontal)).to be_nil
1235
1615
  end
1236
1616
 
1237
1617
  it 'should cause error if a negative argument is passed in' do
1238
1618
  expect {
1239
- @worksheet.get_column_alignment(-1, :horizontal)
1619
+ subject.get_column_alignment(-1, :horizontal)
1240
1620
  }.to raise_error(RuntimeError)
1241
1621
  end
1242
1622
 
1243
1623
  it 'should return correct horizontal alignment if it is set for that column' do
1244
- @worksheet.change_column_horizontal_alignment(0, 'center')
1245
- expect(@worksheet.get_column_alignment(0, :horizontal)).to eq('center')
1624
+ subject.change_column_horizontal_alignment(0, 'center')
1625
+ expect(subject.get_column_alignment(0, :horizontal)).to eq('center')
1246
1626
  end
1247
1627
  end
1248
1628
 
1249
1629
  describe '.get_column_vertical_alignment' do
1250
1630
  it 'should return nil if no alignment specified for column' do
1251
- expect(@worksheet.get_column_alignment(0, :vertical)).to be_nil
1631
+ expect(subject.get_column_alignment(0, :vertical)).to be_nil
1252
1632
  end
1253
1633
 
1254
1634
  it 'should return nil if a column which does not exist is passed in' do
1255
- expect(@worksheet.get_column_alignment(11, :vertical)).to be_nil
1635
+ expect(subject.get_column_alignment(11, :vertical)).to be_nil
1256
1636
  end
1257
1637
 
1258
1638
  it 'should cause error if a negative argument is passed in' do
1259
1639
  expect {
1260
- @worksheet.get_column_alignment(-1, :vertical)
1640
+ subject.get_column_alignment(-1, :vertical)
1261
1641
  }.to raise_error(RuntimeError)
1262
1642
  end
1263
1643
 
1264
1644
  it 'should return correct vertical alignment if it is set for that column' do
1265
- @worksheet.change_column_vertical_alignment(0, 'center')
1266
- expect(@worksheet.get_column_alignment(0, :vertical)).to eq('center')
1645
+ subject.change_column_vertical_alignment(0, 'center')
1646
+ expect(subject.get_column_alignment(0, :vertical)).to eq('center')
1267
1647
  end
1268
1648
  end
1269
1649
 
1270
1650
  describe '.get_column_border' do
1271
1651
  it 'should return nil if no border is specified for that column in that direction' do
1272
- expect(@worksheet.get_column_border(0, :diagonal)).to be_nil
1652
+ expect(subject.get_column_border(0, :diagonal)).to be_nil
1273
1653
  end
1274
1654
 
1275
1655
  it 'should return type of border that this column has on diagonal' do
1276
- @worksheet.change_column_border(0, :diagonal, 'thin')
1277
- expect(@worksheet.get_column_border(0, :diagonal)).to eq('thin')
1656
+ subject.change_column_border(0, :diagonal, 'thin')
1657
+ expect(subject.get_column_border(0, :diagonal)).to eq('thin')
1278
1658
  end
1279
1659
 
1280
1660
  it 'should cause error if a negative argument is passed in' do
1281
1661
  expect {
1282
- @worksheet.get_column_border(-1, :diagonal)
1662
+ subject.get_column_border(-1, :diagonal)
1283
1663
  }.to raise_error(RuntimeError)
1284
1664
  end
1285
1665
 
1286
1666
  it 'should return nil if a column which does not exist is passed in' do
1287
- expect(@worksheet.get_column_border(11, :diagonal)).to be_nil
1667
+ expect(subject.get_column_border(11, :diagonal)).to be_nil
1288
1668
  end
1289
1669
  end
1290
1670
 
1291
1671
  describe '@column_range' do
1292
1672
  it 'should properly handle range addition and modification' do
1293
1673
  # Ranges should be empty for brand new worskeet
1294
- expect(@worksheet.cols.size).to eq(0)
1674
+ expect(subject.cols.size).to eq(0)
1295
1675
 
1296
1676
  # Range should be created if the column has not been touched before
1297
- @worksheet.change_column_width(0, 30)
1298
- expect(@worksheet.get_column_width(0)).to eq(30)
1299
- expect(@worksheet.cols.size).to eq(1)
1677
+ subject.change_column_width(0, 30)
1678
+ expect(subject.get_column_width(0)).to eq(30)
1679
+ expect(subject.cols.size).to eq(1)
1300
1680
 
1301
1681
  # Existing range should be reused
1302
- @worksheet.change_column_width(0, 20)
1303
- expect(@worksheet.get_column_width(0)).to eq(20)
1304
- expect(@worksheet.cols.size).to eq(1)
1682
+ subject.change_column_width(0, 20)
1683
+ expect(subject.get_column_width(0)).to eq(20)
1684
+ expect(subject.cols.size).to eq(1)
1305
1685
 
1306
1686
  # Creation of the new range should not affect previously changed columns
1307
- @worksheet.change_column_width(1, 30)
1308
- expect(@worksheet.get_column_width(1)).to eq(30)
1309
- expect(@worksheet.get_column_width(0)).to eq(20)
1310
- expect(@worksheet.cols.size).to eq(2)
1687
+ subject.change_column_width(1, 30)
1688
+ expect(subject.get_column_width(1)).to eq(30)
1689
+ expect(subject.get_column_width(0)).to eq(20)
1690
+ expect(subject.cols.size).to eq(2)
1311
1691
 
1312
- @worksheet.cols.clear
1313
- @worksheet.cols << RubyXL::ColumnRange.new(:min => 1, :max => 9, :width => 33) # Note that this is raw width
1692
+ subject.cols.clear
1693
+ subject.cols << RubyXL::ColumnRange.new(:min => 1, :max => 9, :width => 33) # Note that this is raw width
1314
1694
 
1315
- r = @worksheet.cols.locate_range(3)
1695
+ r = subject.cols.locate_range(3)
1316
1696
  expect(r.min).to eq(1)
1317
1697
  expect(r.max).to eq(9)
1318
1698
 
1319
1699
  # When a column is modified at the beginning of the range, it should shrink to the right
1320
- @worksheet.change_column_width(0, 20)
1321
- expect(@worksheet.cols.size).to eq(2)
1322
- expect(@worksheet.get_column_width(0)).to eq(20)
1323
- expect(@worksheet.get_column_width(1)).to eq(32)
1700
+ subject.change_column_width(0, 20)
1701
+ expect(subject.cols.size).to eq(2)
1702
+ expect(subject.get_column_width(0)).to eq(20)
1703
+ expect(subject.get_column_width(1)).to eq(32)
1324
1704
 
1325
- r = @worksheet.cols.locate_range(3)
1705
+ r = subject.cols.locate_range(3)
1326
1706
  expect(r.min).to eq(2)
1327
1707
  expect(r.max).to eq(9)
1328
1708
 
1329
1709
  # When a column is modified at the beginning of the range, it should shrink to the left
1330
- @worksheet.change_column_width(8, 30)
1331
- expect(@worksheet.cols.size).to eq(3)
1332
- expect(@worksheet.get_column_width(8)).to eq(30)
1710
+ subject.change_column_width(8, 30)
1711
+ expect(subject.cols.size).to eq(3)
1712
+ expect(subject.get_column_width(8)).to eq(30)
1333
1713
 
1334
- r = @worksheet.cols.locate_range(3)
1714
+ r = subject.cols.locate_range(3)
1335
1715
  expect(r.min).to eq(2)
1336
1716
  expect(r.max).to eq(8)
1337
1717
 
1338
1718
  # When a column is modified in the middle of the range, it should split into two
1339
- @worksheet.change_column_width(4, 15)
1340
- expect(@worksheet.cols.size).to eq(5)
1341
- expect(@worksheet.get_column_width(3)).to eq(32)
1719
+ subject.change_column_width(4, 15)
1720
+ expect(subject.cols.size).to eq(5)
1721
+ expect(subject.get_column_width(3)).to eq(32)
1342
1722
 
1343
- r = @worksheet.cols.locate_range(2)
1723
+ r = subject.cols.locate_range(2)
1344
1724
  expect(r.min).to eq(2)
1345
1725
  expect(r.max).to eq(4)
1346
1726
 
1347
- expect(@worksheet.get_column_width(4)).to eq(15)
1727
+ expect(subject.get_column_width(4)).to eq(15)
1348
1728
 
1349
- r = @worksheet.cols.locate_range(4)
1729
+ r = subject.cols.locate_range(4)
1350
1730
  expect(r.min).to eq(5)
1351
1731
  expect(r.max).to eq(5)
1352
1732
 
1353
- expect(@worksheet.get_column_width(5)).to eq(32)
1733
+ expect(subject.get_column_width(5)).to eq(32)
1354
1734
 
1355
- r = @worksheet.cols.locate_range(6)
1735
+ r = subject.cols.locate_range(6)
1356
1736
  expect(r.min).to eq(6)
1357
1737
  expect(r.max).to eq(8)
1738
+ end
1739
+ end
1358
1740
 
1741
+ describe 'forbidden sheet names' do
1742
+ it 'should stream a workbook successfully' do
1743
+ subject.sheet_name = 'Test Name'
1744
+ subject.workbook.stream
1359
1745
  end
1360
1746
 
1361
- end
1747
+ it 'should throw an error when forbidden characters are used in the sheet name' do
1748
+ subject.sheet_name = 'Some [Special] Name'
1749
+ expect { subject.workbook.stream }.to raise_error(RuntimeError)
1750
+ end
1362
1751
 
1752
+ it 'should throw an error when forbidden name is used' do
1753
+ subject.sheet_name = 'History'
1754
+ expect { subject.workbook.stream }.to raise_error(RuntimeError)
1755
+ end
1756
+ end
1363
1757
  end