rubyXL 3.4.18 → 3.4.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (453) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -8
  3. data/Gemfile.lock +37 -30
  4. data/README.rdoc +18 -9
  5. data/Rakefile +24 -25
  6. data/VERSION +1 -1
  7. data/lib/rubyXL/cell.rb +2 -4
  8. data/lib/rubyXL/convenience_methods/cell.rb +35 -31
  9. data/lib/rubyXL/convenience_methods/color.rb +3 -7
  10. data/lib/rubyXL/convenience_methods/workbook.rb +9 -4
  11. data/lib/rubyXL/convenience_methods/worksheet.rb +3 -4
  12. data/lib/rubyXL/objects/border.rb +0 -3
  13. data/lib/rubyXL/objects/calculation_chain.rb +2 -2
  14. data/lib/rubyXL/objects/cell_style.rb +1 -3
  15. data/lib/rubyXL/objects/chartsheet.rb +5 -9
  16. data/lib/rubyXL/objects/color.rb +1 -3
  17. data/lib/rubyXL/objects/column_range.rb +0 -3
  18. data/lib/rubyXL/objects/comments.rb +1 -4
  19. data/lib/rubyXL/objects/connection.rb +11 -11
  20. data/lib/rubyXL/objects/container_nodes.rb +1 -5
  21. data/lib/rubyXL/objects/content_types.rb +3 -6
  22. data/lib/rubyXL/objects/data_validation.rb +0 -2
  23. data/lib/rubyXL/objects/document_properties.rb +9 -13
  24. data/lib/rubyXL/objects/extensions.rb +0 -2
  25. data/lib/rubyXL/objects/external_links.rb +4 -6
  26. data/lib/rubyXL/objects/fill.rb +2 -5
  27. data/lib/rubyXL/objects/filters.rb +5 -7
  28. data/lib/rubyXL/objects/font.rb +2 -4
  29. data/lib/rubyXL/objects/formula.rb +3 -5
  30. data/lib/rubyXL/objects/ooxml_object.rb +13 -18
  31. data/lib/rubyXL/objects/query_table.rb +3 -3
  32. data/lib/rubyXL/objects/reference.rb +6 -8
  33. data/lib/rubyXL/objects/relationships.rb +5 -10
  34. data/lib/rubyXL/objects/root.rb +0 -2
  35. data/lib/rubyXL/objects/shared_strings.rb +3 -6
  36. data/lib/rubyXL/objects/sheet_common.rb +1 -3
  37. data/lib/rubyXL/objects/sheet_data.rb +4 -7
  38. data/lib/rubyXL/objects/simple_types.rb +3 -1
  39. data/lib/rubyXL/objects/storage.rb +51 -51
  40. data/lib/rubyXL/objects/stylesheet.rb +8 -15
  41. data/lib/rubyXL/objects/text.rb +5 -7
  42. data/lib/rubyXL/objects/theme.rb +4 -7
  43. data/lib/rubyXL/objects/workbook.rb +25 -27
  44. data/lib/rubyXL/objects/worksheet.rb +26 -22
  45. data/lib/rubyXL/parser.rb +1 -3
  46. data/lib/rubyXL/worksheet.rb +83 -84
  47. data/lib/rubyXL.rb +0 -1
  48. data/rdoc/README_rdoc.html +29 -24
  49. data/rdoc/RubyXL/AExtension.html +2 -2
  50. data/rdoc/RubyXL/AExtensionStorageArea.html +2 -2
  51. data/rdoc/RubyXL/ActiveX.html +4 -4
  52. data/rdoc/RubyXL/ActiveXBinary.html +2 -2
  53. data/rdoc/RubyXL/AdjustHandleList.html +2 -2
  54. data/rdoc/RubyXL/Alignment.html +2 -2
  55. data/rdoc/RubyXL/AlternateContent.html +2 -2
  56. data/rdoc/RubyXL/Authors.html +2 -2
  57. data/rdoc/RubyXL/AutoFilter.html +2 -2
  58. data/rdoc/RubyXL/AutoFilterColumn.html +2 -2
  59. data/rdoc/RubyXL/BinaryImageFile.html +2 -2
  60. data/rdoc/RubyXL/BodyProperties.html +2 -2
  61. data/rdoc/RubyXL/BooleanNode.html +2 -2
  62. data/rdoc/RubyXL/BooleanValue.html +2 -2
  63. data/rdoc/RubyXL/Border.html +6 -6
  64. data/rdoc/RubyXL/BorderEdge.html +4 -4
  65. data/rdoc/RubyXL/Borders.html +3 -3
  66. data/rdoc/RubyXL/Break.html +2 -2
  67. data/rdoc/RubyXL/BreakList.html +2 -2
  68. data/rdoc/RubyXL/CT_AdjPoint2D.html +2 -2
  69. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +2 -2
  70. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +2 -2
  71. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +2 -2
  72. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +2 -2
  73. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +2 -2
  74. data/rdoc/RubyXL/CT_Backdrop.html +2 -2
  75. data/rdoc/RubyXL/CT_Bevel.html +2 -2
  76. data/rdoc/RubyXL/CT_BiLevelEffect.html +2 -2
  77. data/rdoc/RubyXL/CT_BlendEffect.html +2 -2
  78. data/rdoc/RubyXL/CT_Blip.html +2 -2
  79. data/rdoc/RubyXL/CT_BlipFillProperties.html +2 -2
  80. data/rdoc/RubyXL/CT_BlurEffect.html +2 -2
  81. data/rdoc/RubyXL/CT_Camera.html +2 -2
  82. data/rdoc/RubyXL/CT_Color.html +2 -2
  83. data/rdoc/RubyXL/CT_ColorChangeEffect.html +2 -2
  84. data/rdoc/RubyXL/CT_ColorMapping.html +2 -2
  85. data/rdoc/RubyXL/CT_ColorScheme.html +2 -2
  86. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +2 -2
  87. data/rdoc/RubyXL/CT_ConnectionSite.html +2 -2
  88. data/rdoc/RubyXL/CT_ConnectionSiteList.html +2 -2
  89. data/rdoc/RubyXL/CT_DashStop.html +2 -2
  90. data/rdoc/RubyXL/CT_DashStopList.html +2 -2
  91. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +2 -2
  92. data/rdoc/RubyXL/CT_DuotoneEffect.html +2 -2
  93. data/rdoc/RubyXL/CT_EffectContainer.html +2 -2
  94. data/rdoc/RubyXL/CT_EffectList.html +2 -2
  95. data/rdoc/RubyXL/CT_EffectReference.html +2 -2
  96. data/rdoc/RubyXL/CT_EffectStyleItem.html +2 -2
  97. data/rdoc/RubyXL/CT_EffectStyleList.html +2 -2
  98. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +2 -2
  99. data/rdoc/RubyXL/CT_FillEffect.html +2 -2
  100. data/rdoc/RubyXL/CT_FillOverlayEffect.html +2 -2
  101. data/rdoc/RubyXL/CT_FillStyleList.html +2 -2
  102. data/rdoc/RubyXL/CT_FlatText.html +2 -2
  103. data/rdoc/RubyXL/CT_FontCollection.html +2 -2
  104. data/rdoc/RubyXL/CT_FontReference.html +2 -2
  105. data/rdoc/RubyXL/CT_GeomGuideList.html +2 -2
  106. data/rdoc/RubyXL/CT_GlowEffect.html +2 -2
  107. data/rdoc/RubyXL/CT_GradientFillProperties.html +2 -2
  108. data/rdoc/RubyXL/CT_GradientStop.html +2 -2
  109. data/rdoc/RubyXL/CT_GradientStopList.html +2 -2
  110. data/rdoc/RubyXL/CT_HSLEffect.html +2 -2
  111. data/rdoc/RubyXL/CT_HslColor.html +2 -2
  112. data/rdoc/RubyXL/CT_Hyperlink.html +2 -2
  113. data/rdoc/RubyXL/CT_InnerShadowEffect.html +2 -2
  114. data/rdoc/RubyXL/CT_LightRig.html +2 -2
  115. data/rdoc/RubyXL/CT_LineEndProperties.html +2 -2
  116. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +2 -2
  117. data/rdoc/RubyXL/CT_LineProperties.html +2 -2
  118. data/rdoc/RubyXL/CT_LineStyleList.html +2 -2
  119. data/rdoc/RubyXL/CT_LinearShadeProperties.html +2 -2
  120. data/rdoc/RubyXL/CT_LuminanceEffect.html +2 -2
  121. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +2 -2
  122. data/rdoc/RubyXL/CT_OuterShadowEffect.html +2 -2
  123. data/rdoc/RubyXL/CT_Path2D.html +2 -2
  124. data/rdoc/RubyXL/CT_Path2DArcTo.html +2 -2
  125. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +2 -2
  126. data/rdoc/RubyXL/CT_Path2DList.html +2 -2
  127. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +2 -2
  128. data/rdoc/RubyXL/CT_Path2DTo.html +2 -2
  129. data/rdoc/RubyXL/CT_PathShadeProperties.html +2 -2
  130. data/rdoc/RubyXL/CT_PatternFillProperties.html +2 -2
  131. data/rdoc/RubyXL/CT_Point3D.html +2 -2
  132. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +2 -2
  133. data/rdoc/RubyXL/CT_PresetColor.html +2 -2
  134. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +2 -2
  135. data/rdoc/RubyXL/CT_PresetShadowEffect.html +2 -2
  136. data/rdoc/RubyXL/CT_PresetTextShape.html +2 -2
  137. data/rdoc/RubyXL/CT_ReflectionEffect.html +2 -2
  138. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +2 -2
  139. data/rdoc/RubyXL/CT_RelativeRect.html +2 -2
  140. data/rdoc/RubyXL/CT_SRgbColor.html +2 -2
  141. data/rdoc/RubyXL/CT_ScRgbColor.html +2 -2
  142. data/rdoc/RubyXL/CT_Scene3D.html +2 -2
  143. data/rdoc/RubyXL/CT_SchemeColor.html +2 -2
  144. data/rdoc/RubyXL/CT_Shape3D.html +2 -2
  145. data/rdoc/RubyXL/CT_ShapeStyle.html +2 -2
  146. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +2 -2
  147. data/rdoc/RubyXL/CT_SphereCoords.html +2 -2
  148. data/rdoc/RubyXL/CT_StretchInfoProperties.html +2 -2
  149. data/rdoc/RubyXL/CT_StyleMatrix.html +2 -2
  150. data/rdoc/RubyXL/CT_StyleMatrixReference.html +2 -2
  151. data/rdoc/RubyXL/CT_SupplementalFont.html +2 -2
  152. data/rdoc/RubyXL/CT_SystemColor.html +2 -2
  153. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +2 -2
  154. data/rdoc/RubyXL/CT_TextBlipBullet.html +2 -2
  155. data/rdoc/RubyXL/CT_TextCharBullet.html +2 -2
  156. data/rdoc/RubyXL/CT_TextCharacterProperties.html +2 -2
  157. data/rdoc/RubyXL/CT_TextFont.html +2 -2
  158. data/rdoc/RubyXL/CT_TextListStyle.html +2 -2
  159. data/rdoc/RubyXL/CT_TextNormalAutofit.html +2 -2
  160. data/rdoc/RubyXL/CT_TextParagraphProperties.html +2 -2
  161. data/rdoc/RubyXL/CT_TextSpacing.html +2 -2
  162. data/rdoc/RubyXL/CT_TextTabStop.html +2 -2
  163. data/rdoc/RubyXL/CT_TextTabStopList.html +2 -2
  164. data/rdoc/RubyXL/CT_TileInfoProperties.html +2 -2
  165. data/rdoc/RubyXL/CT_TintEffect.html +2 -2
  166. data/rdoc/RubyXL/CT_Transform2D.html +2 -2
  167. data/rdoc/RubyXL/CT_TransformEffect.html +2 -2
  168. data/rdoc/RubyXL/CT_Vector3D.html +2 -2
  169. data/rdoc/RubyXL/CT_XYAdjustHandle.html +2 -2
  170. data/rdoc/RubyXL/CalculationChain.html +2 -2
  171. data/rdoc/RubyXL/CalculationChainCell.html +2 -2
  172. data/rdoc/RubyXL/CalculationProperties.html +2 -2
  173. data/rdoc/RubyXL/Cell.html +17 -17
  174. data/rdoc/RubyXL/CellConvenienceMethods.html +105 -51
  175. data/rdoc/RubyXL/CellExt.html +2 -2
  176. data/rdoc/RubyXL/CellSmartTag.html +2 -2
  177. data/rdoc/RubyXL/CellSmartTagProperty.html +2 -2
  178. data/rdoc/RubyXL/CellSmartTags.html +2 -2
  179. data/rdoc/RubyXL/CellStyle.html +2 -2
  180. data/rdoc/RubyXL/CellStyleXFs.html +3 -3
  181. data/rdoc/RubyXL/CellStyles.html +3 -3
  182. data/rdoc/RubyXL/CellValue.html +3 -3
  183. data/rdoc/RubyXL/CellWatch.html +2 -2
  184. data/rdoc/RubyXL/CellWatches.html +2 -2
  185. data/rdoc/RubyXL/CellXFs.html +4 -6
  186. data/rdoc/RubyXL/ChartColorsFile.html +2 -2
  187. data/rdoc/RubyXL/ChartFile.html +3 -3
  188. data/rdoc/RubyXL/ChartStyleFile.html +2 -2
  189. data/rdoc/RubyXL/ChartUserShapesFile.html +2 -2
  190. data/rdoc/RubyXL/Chartsheet.html +3 -3
  191. data/rdoc/RubyXL/ChartsheetPageSetup.html +2 -2
  192. data/rdoc/RubyXL/ChartsheetProperties.html +2 -2
  193. data/rdoc/RubyXL/ChartsheetProtection.html +2 -2
  194. data/rdoc/RubyXL/ChartsheetView.html +2 -2
  195. data/rdoc/RubyXL/ChartsheetViews.html +2 -2
  196. data/rdoc/RubyXL/Color.html +4 -4
  197. data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +4 -4
  198. data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +8 -8
  199. data/rdoc/RubyXL/ColorConvenienceClasses.html +2 -2
  200. data/rdoc/RubyXL/ColorConvenienceMethods.html +3 -3
  201. data/rdoc/RubyXL/ColorFilter.html +2 -2
  202. data/rdoc/RubyXL/ColorScale.html +2 -2
  203. data/rdoc/RubyXL/ColorSet.html +2 -2
  204. data/rdoc/RubyXL/Colors.html +2 -2
  205. data/rdoc/RubyXL/ColumnRange.html +5 -5
  206. data/rdoc/RubyXL/ColumnRanges.html +6 -6
  207. data/rdoc/RubyXL/Comment.html +2 -2
  208. data/rdoc/RubyXL/CommentList.html +2 -2
  209. data/rdoc/RubyXL/CommentsFile.html +3 -3
  210. data/rdoc/RubyXL/ConditionalFormatValue.html +2 -2
  211. data/rdoc/RubyXL/ConditionalFormatting.html +2 -2
  212. data/rdoc/RubyXL/ConditionalFormattingRule.html +2 -2
  213. data/rdoc/RubyXL/Connection.html +2 -2
  214. data/rdoc/RubyXL/ConnectionTable.html +2 -2
  215. data/rdoc/RubyXL/ConnectionTables.html +2 -2
  216. data/rdoc/RubyXL/ConnectionTextField.html +2 -2
  217. data/rdoc/RubyXL/ConnectionTextFields.html +2 -2
  218. data/rdoc/RubyXL/Connections.html +2 -2
  219. data/rdoc/RubyXL/ContentTypeDefault.html +2 -2
  220. data/rdoc/RubyXL/ContentTypeOverride.html +2 -2
  221. data/rdoc/RubyXL/ContentTypes.html +6 -6
  222. data/rdoc/RubyXL/ControlPropertiesFile.html +2 -2
  223. data/rdoc/RubyXL/CorePropertiesFile.html +11 -11
  224. data/rdoc/RubyXL/CustomColor.html +2 -2
  225. data/rdoc/RubyXL/CustomColorList.html +2 -2
  226. data/rdoc/RubyXL/CustomFilter.html +2 -2
  227. data/rdoc/RubyXL/CustomFilters.html +2 -2
  228. data/rdoc/RubyXL/CustomGeometry.html +2 -2
  229. data/rdoc/RubyXL/CustomProperties.html +2 -2
  230. data/rdoc/RubyXL/CustomPropertiesFile.html +2 -2
  231. data/rdoc/RubyXL/CustomProperty.html +2 -2
  232. data/rdoc/RubyXL/CustomPropertyFile.html +2 -2
  233. data/rdoc/RubyXL/CustomSheetView.html +2 -2
  234. data/rdoc/RubyXL/CustomSheetViews.html +2 -2
  235. data/rdoc/RubyXL/CustomWorkbookView.html +2 -2
  236. data/rdoc/RubyXL/CustomWorkbookViews.html +2 -2
  237. data/rdoc/RubyXL/CustomXMLFile.html +2 -2
  238. data/rdoc/RubyXL/DXF.html +2 -2
  239. data/rdoc/RubyXL/DXFs.html +2 -2
  240. data/rdoc/RubyXL/DataBar.html +2 -2
  241. data/rdoc/RubyXL/DataConsolidate.html +2 -2
  242. data/rdoc/RubyXL/DataConsolidationReference.html +2 -2
  243. data/rdoc/RubyXL/DataConsolidationReferences.html +2 -2
  244. data/rdoc/RubyXL/DataType.html +2 -2
  245. data/rdoc/RubyXL/DataValidation.html +2 -2
  246. data/rdoc/RubyXL/DataValidations.html +2 -2
  247. data/rdoc/RubyXL/DateGroupItem.html +2 -2
  248. data/rdoc/RubyXL/DefinedName.html +2 -2
  249. data/rdoc/RubyXL/DefinedNameExt.html +2 -2
  250. data/rdoc/RubyXL/DefinedNames.html +2 -2
  251. data/rdoc/RubyXL/DefinedNamesExt.html +2 -2
  252. data/rdoc/RubyXL/DocumentPropertiesFile.html +4 -4
  253. data/rdoc/RubyXL/DrawingFile.html +3 -3
  254. data/rdoc/RubyXL/DynamicFilter.html +2 -2
  255. data/rdoc/RubyXL/EmbeddedControl.html +2 -2
  256. data/rdoc/RubyXL/EmbeddedControls.html +2 -2
  257. data/rdoc/RubyXL/Extension.html +2 -2
  258. data/rdoc/RubyXL/ExtensionStorageArea.html +2 -2
  259. data/rdoc/RubyXL/Extents.html +2 -2
  260. data/rdoc/RubyXL/ExternalBook.html +2 -2
  261. data/rdoc/RubyXL/ExternalLinksFile.html +3 -3
  262. data/rdoc/RubyXL/ExternalReference.html +2 -2
  263. data/rdoc/RubyXL/ExternalReferences.html +2 -2
  264. data/rdoc/RubyXL/ExtraColorSchemeList.html +2 -2
  265. data/rdoc/RubyXL/FieldItem.html +2 -2
  266. data/rdoc/RubyXL/FileRecoveryProperties.html +2 -2
  267. data/rdoc/RubyXL/FileSharing.html +2 -2
  268. data/rdoc/RubyXL/FileVersion.html +2 -2
  269. data/rdoc/RubyXL/Fill.html +3 -3
  270. data/rdoc/RubyXL/Fills.html +3 -3
  271. data/rdoc/RubyXL/FilterContainer.html +2 -2
  272. data/rdoc/RubyXL/FloatNode.html +2 -2
  273. data/rdoc/RubyXL/FloatValue.html +2 -2
  274. data/rdoc/RubyXL/Font.html +5 -5
  275. data/rdoc/RubyXL/FontConvenienceMethods.html +3 -3
  276. data/rdoc/RubyXL/FontScheme.html +2 -2
  277. data/rdoc/RubyXL/Fonts.html +3 -3
  278. data/rdoc/RubyXL/Formula.html +2 -2
  279. data/rdoc/RubyXL/FunctionGroup.html +2 -2
  280. data/rdoc/RubyXL/FunctionGroups.html +2 -2
  281. data/rdoc/RubyXL/GenericStorageObject.html +5 -5
  282. data/rdoc/RubyXL/GradientFill.html +2 -2
  283. data/rdoc/RubyXL/HeaderFooterSettings.html +2 -2
  284. data/rdoc/RubyXL/Hyperlink.html +2 -2
  285. data/rdoc/RubyXL/HyperlinkRelFile.html +2 -2
  286. data/rdoc/RubyXL/Hyperlinks.html +2 -2
  287. data/rdoc/RubyXL/IconFilter.html +2 -2
  288. data/rdoc/RubyXL/IconSet.html +2 -2
  289. data/rdoc/RubyXL/IgnoredError.html +2 -2
  290. data/rdoc/RubyXL/IgnoredErrors.html +2 -2
  291. data/rdoc/RubyXL/IndexedColors.html +2 -2
  292. data/rdoc/RubyXL/InputCells.html +2 -2
  293. data/rdoc/RubyXL/IntegerNode.html +2 -2
  294. data/rdoc/RubyXL/IntegerValue.html +2 -2
  295. data/rdoc/RubyXL/LegacyCell.html +3 -3
  296. data/rdoc/RubyXL/LegacyWorksheet.html +3 -3
  297. data/rdoc/RubyXL/MRUColors.html +2 -2
  298. data/rdoc/RubyXL/MacrosFile.html +2 -2
  299. data/rdoc/RubyXL/MergedCell.html +2 -2
  300. data/rdoc/RubyXL/MergedCells.html +2 -2
  301. data/rdoc/RubyXL/NumFmt.html +2 -2
  302. data/rdoc/RubyXL/NumberFormat.html +4 -4
  303. data/rdoc/RubyXL/NumberFormats.html +3 -3
  304. data/rdoc/RubyXL/OLEObject.html +2 -2
  305. data/rdoc/RubyXL/OLEObjectFile.html +2 -2
  306. data/rdoc/RubyXL/OLEObjects.html +2 -2
  307. data/rdoc/RubyXL/OLESize.html +2 -2
  308. data/rdoc/RubyXL/OOXMLContainerObject.html +8 -8
  309. data/rdoc/RubyXL/OOXMLIgnored.html +4 -4
  310. data/rdoc/RubyXL/OOXMLObject.html +3 -3
  311. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +18 -18
  312. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +14 -14
  313. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +16 -16
  314. data/rdoc/RubyXL/OOXMLTopLevelObject.html +8 -8
  315. data/rdoc/RubyXL/OdbcOleDbProperties.html +2 -2
  316. data/rdoc/RubyXL/Offset.html +2 -2
  317. data/rdoc/RubyXL/OlapProperties.html +2 -2
  318. data/rdoc/RubyXL/OleItem.html +2 -2
  319. data/rdoc/RubyXL/OleItems.html +2 -2
  320. data/rdoc/RubyXL/OleLink.html +2 -2
  321. data/rdoc/RubyXL/OutlineProperties.html +2 -2
  322. data/rdoc/RubyXL/PageMargins.html +2 -2
  323. data/rdoc/RubyXL/PageSetup.html +2 -2
  324. data/rdoc/RubyXL/PageSetupProperties.html +2 -2
  325. data/rdoc/RubyXL/Pane.html +2 -2
  326. data/rdoc/RubyXL/Parser.html +5 -5
  327. data/rdoc/RubyXL/PatternFill.html +2 -2
  328. data/rdoc/RubyXL/PhoneticProperties.html +2 -2
  329. data/rdoc/RubyXL/PhoneticRun.html +2 -2
  330. data/rdoc/RubyXL/PivotArea.html +2 -2
  331. data/rdoc/RubyXL/PivotCache.html +2 -2
  332. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +2 -2
  333. data/rdoc/RubyXL/PivotCacheRecordsFile.html +2 -2
  334. data/rdoc/RubyXL/PivotCaches.html +2 -2
  335. data/rdoc/RubyXL/PivotReference.html +2 -2
  336. data/rdoc/RubyXL/PivotReferences.html +2 -2
  337. data/rdoc/RubyXL/PivotTableFile.html +2 -2
  338. data/rdoc/RubyXL/PivotTableSelection.html +2 -2
  339. data/rdoc/RubyXL/PresetGeometry.html +2 -2
  340. data/rdoc/RubyXL/PrintOptions.html +2 -2
  341. data/rdoc/RubyXL/PrinterSettingsFile.html +2 -2
  342. data/rdoc/RubyXL/ProtectedRange.html +2 -2
  343. data/rdoc/RubyXL/ProtectedRanges.html +2 -2
  344. data/rdoc/RubyXL/Protection.html +2 -2
  345. data/rdoc/RubyXL/QueryParameter.html +2 -2
  346. data/rdoc/RubyXL/QueryParameters.html +2 -2
  347. data/rdoc/RubyXL/QueryTable.html +2 -2
  348. data/rdoc/RubyXL/QueryTableDeletedField.html +2 -2
  349. data/rdoc/RubyXL/QueryTableDeletedFields.html +2 -2
  350. data/rdoc/RubyXL/QueryTableField.html +2 -2
  351. data/rdoc/RubyXL/QueryTableFields.html +2 -2
  352. data/rdoc/RubyXL/QueryTableRefresh.html +2 -2
  353. data/rdoc/RubyXL/RID.html +2 -2
  354. data/rdoc/RubyXL/RawOOXML.html +4 -4
  355. data/rdoc/RubyXL/Reference.html +36 -17
  356. data/rdoc/RubyXL/Relationship.html +2 -2
  357. data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +3 -3
  358. data/rdoc/RubyXL/RelationshipSupport.html +8 -8
  359. data/rdoc/RubyXL/RevisionPointer.html +2 -2
  360. data/rdoc/RubyXL/RichText.html +5 -4
  361. data/rdoc/RubyXL/RichTextRun.html +3 -3
  362. data/rdoc/RubyXL/Row.html +11 -11
  363. data/rdoc/RubyXL/RowExt.html +2 -2
  364. data/rdoc/RubyXL/RunProperties.html +2 -2
  365. data/rdoc/RubyXL/Scenario.html +2 -2
  366. data/rdoc/RubyXL/Scenarios.html +2 -2
  367. data/rdoc/RubyXL/Selection.html +3 -3
  368. data/rdoc/RubyXL/ShapeGuide.html +2 -2
  369. data/rdoc/RubyXL/ShapeTextRectangle.html +2 -2
  370. data/rdoc/RubyXL/SharedStringsTable.html +9 -9
  371. data/rdoc/RubyXL/Sheet.html +2 -2
  372. data/rdoc/RubyXL/SheetCalculationProperties.html +2 -2
  373. data/rdoc/RubyXL/SheetData.html +4 -4
  374. data/rdoc/RubyXL/SheetDataExt.html +2 -2
  375. data/rdoc/RubyXL/SheetDataSet.html +2 -2
  376. data/rdoc/RubyXL/SheetMetadata.html +108 -0
  377. data/rdoc/RubyXL/SheetName.html +2 -2
  378. data/rdoc/RubyXL/SheetNames.html +2 -2
  379. data/rdoc/RubyXL/Sheets.html +2 -2
  380. data/rdoc/RubyXL/SlicerCacheFile.html +2 -2
  381. data/rdoc/RubyXL/SlicerFile.html +2 -2
  382. data/rdoc/RubyXL/SmartTagProperties.html +2 -2
  383. data/rdoc/RubyXL/SmartTagType.html +2 -2
  384. data/rdoc/RubyXL/SmartTagTypes.html +2 -2
  385. data/rdoc/RubyXL/SmartTags.html +2 -2
  386. data/rdoc/RubyXL/SortCondition.html +2 -2
  387. data/rdoc/RubyXL/SortState.html +2 -2
  388. data/rdoc/RubyXL/Sqref.html +4 -4
  389. data/rdoc/RubyXL/Stop.html +2 -2
  390. data/rdoc/RubyXL/StringNode.html +2 -2
  391. data/rdoc/RubyXL/StringNodeW3C.html +4 -4
  392. data/rdoc/RubyXL/StringValue.html +2 -2
  393. data/rdoc/RubyXL/Stylesheet.html +7 -7
  394. data/rdoc/RubyXL/TableFile.html +2 -2
  395. data/rdoc/RubyXL/TableParts.html +2 -2
  396. data/rdoc/RubyXL/TableStyle.html +2 -2
  397. data/rdoc/RubyXL/TableStyles.html +2 -2
  398. data/rdoc/RubyXL/Text.html +6 -6
  399. data/rdoc/RubyXL/TextImportSettings.html +2 -2
  400. data/rdoc/RubyXL/Theme.html +5 -5
  401. data/rdoc/RubyXL/ThemeElements.html +2 -2
  402. data/rdoc/RubyXL/ThumbnailFile.html +2 -2
  403. data/rdoc/RubyXL/Top10.html +2 -2
  404. data/rdoc/RubyXL/VMLDrawingFile.html +3 -3
  405. data/rdoc/RubyXL/Variant.html +2 -2
  406. data/rdoc/RubyXL/Vector.html +3 -3
  407. data/rdoc/RubyXL/VectorValue.html +2 -2
  408. data/rdoc/RubyXL/VisualProperties.html +2 -2
  409. data/rdoc/RubyXL/WebPublishObject.html +2 -2
  410. data/rdoc/RubyXL/WebPublishObjects.html +2 -2
  411. data/rdoc/RubyXL/WebPublishingItem.html +2 -2
  412. data/rdoc/RubyXL/WebPublishingItems.html +2 -2
  413. data/rdoc/RubyXL/WebPublishingProperties.html +2 -2
  414. data/rdoc/RubyXL/WebQueryProperties.html +2 -2
  415. data/rdoc/RubyXL/Workbook.html +9 -6
  416. data/rdoc/RubyXL/WorkbookConvenienceMethods.html +65 -21
  417. data/rdoc/RubyXL/WorkbookProperties.html +2 -2
  418. data/rdoc/RubyXL/WorkbookProtection.html +2 -2
  419. data/rdoc/RubyXL/WorkbookRoot.html +7 -7
  420. data/rdoc/RubyXL/WorkbookView.html +2 -2
  421. data/rdoc/RubyXL/WorkbookViews.html +2 -2
  422. data/rdoc/RubyXL/Worksheet.html +32 -8
  423. data/rdoc/RubyXL/WorksheetConvenienceMethods.html +75 -75
  424. data/rdoc/RubyXL/WorksheetDimensions.html +2 -2
  425. data/rdoc/RubyXL/WorksheetFormatProperties.html +2 -2
  426. data/rdoc/RubyXL/WorksheetProperties.html +2 -2
  427. data/rdoc/RubyXL/WorksheetProtection.html +2 -2
  428. data/rdoc/RubyXL/WorksheetView.html +2 -2
  429. data/rdoc/RubyXL/WorksheetViews.html +2 -2
  430. data/rdoc/RubyXL/XF.html +2 -2
  431. data/rdoc/RubyXL.html +4 -2
  432. data/rdoc/created.rid +44 -44
  433. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  434. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  435. data/rdoc/index.html +4 -3
  436. data/rdoc/js/navigation.js.gz +0 -0
  437. data/rdoc/js/search_index.js +1 -1
  438. data/rdoc/js/search_index.js.gz +0 -0
  439. data/rdoc/js/searcher.js.gz +0 -0
  440. data/rdoc/table_of_contents.html +37 -3
  441. data/rubyXL.gemspec +5 -4
  442. data/spec/lib/cell_spec.rb +14 -7
  443. data/spec/lib/color_spec.rb +1 -1
  444. data/spec/lib/parser_spec.rb +24 -27
  445. data/spec/lib/reference_spec.rb +9 -3
  446. data/spec/lib/rgb_color_spec.rb +14 -3
  447. data/spec/lib/stylesheet_spec.rb +8 -11
  448. data/spec/lib/text_spec.rb +1 -5
  449. data/spec/lib/workbook_spec.rb +14 -4
  450. data/spec/lib/worksheet_spec.rb +577 -535
  451. data/spec/spec_helper.rb +2 -0
  452. data/test/test_parse_write.rb +3 -3
  453. metadata +4 -3
@@ -4,458 +4,465 @@ require 'rubyXL/convenience_methods/worksheet'
4
4
  SKIP_ROW_COL = 3
5
5
 
6
6
  describe RubyXL::Worksheet do
7
- before(:each) do
8
- @workbook = RubyXL::Workbook.new
9
- @worksheet = @workbook.add_worksheet
10
-
11
- (0..10).each do |i|
12
- (0..10).each do |j|
13
- next if i == SKIP_ROW_COL || j == SKIP_ROW_COL # Skip some rows/cells
14
- @worksheet.add_cell(i, j, "#{i}:#{j}", "F#{i}:#{j}")
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}")
15
15
  end
16
16
  end
17
17
 
18
- @old_cell = @worksheet[0][0]
19
- @old_cell_value = @worksheet[0][0].value.to_s
20
- @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
21
29
  end
22
30
 
23
31
  describe '.change_row_fill' do
24
32
  it 'should raise error if hex color code not passed' do
25
33
  expect {
26
- @worksheet.change_row_fill(0, 'G')
34
+ subject.change_row_fill(0, 'G')
27
35
  }.to raise_error(RuntimeError)
28
36
  end
29
37
 
30
38
  it 'should raise error if hex color code includes # character' do
31
39
  expect {
32
- @worksheet.change_row_fill(3, '#FFF000')
40
+ subject.change_row_fill(3, '#FFF000')
33
41
  }.to raise_error(RuntimeError)
34
42
  end
35
43
 
36
44
  it 'should make row and cell fill colors equal hex color code passed' do
37
- @worksheet.change_row_fill(0, '111111')
38
- expect(@worksheet.get_row_fill(0)).to eq('111111')
39
- 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')
40
48
  end
41
49
 
42
50
  it 'should cause error if a negative argument is passed in' do
43
51
  expect {
44
- @worksheet.change_row_fill(-1, '111111')
52
+ subject.change_row_fill(-1, '111111')
45
53
  }.to raise_error(RuntimeError)
46
54
  end
47
55
 
48
56
  it 'should create a new row if it did not exist before' do
49
- expect(@worksheet.sheet_data[11]).to be_nil
50
- @worksheet.change_row_fill(11, '111111')
51
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
52
- 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')
53
61
  end
54
62
  end
55
63
 
56
64
  describe '.change_row_font_name' do
57
65
  it 'should make row and cell font names equal font name passed' do
58
- @worksheet.change_row_font_name(0, 'Arial')
59
- expect(@worksheet.get_row_font_name(0)).to eq('Arial')
60
- 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')
61
69
  end
62
70
 
63
71
  it 'should cause error if a negative argument is passed in' do
64
72
  expect {
65
- @worksheet.change_row_font_name(-1, 'Arial')
73
+ subject.change_row_font_name(-1, 'Arial')
66
74
  }.to raise_error(RuntimeError)
67
75
  end
68
76
 
69
77
  it 'should create a new row if it did not exist before' do
70
- expect(@worksheet.sheet_data[11]).to be_nil
71
- @worksheet.change_row_font_name(11, 'Arial')
72
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
73
- 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')
74
82
  end
75
83
  end
76
84
 
77
85
  describe '.change_row_font_size' do
78
86
  it 'should make row and cell font sizes equal font number passed' do
79
- @worksheet.change_row_font_size(0, 20)
80
- expect(@worksheet.get_row_font_size(0)).to eq(20)
81
- 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)
82
90
  end
83
91
 
84
92
  it 'should cause an error if a string passed' do
85
93
  expect {
86
- @worksheet.change_row_font_size(0, '20')
94
+ subject.change_row_font_size(0, '20')
87
95
  }.to raise_error(RuntimeError)
88
96
  end
89
97
 
90
98
  it 'should cause error if a negative argument is passed in' do
91
99
  expect {
92
- @worksheet.change_row_font_size(-1,20)
100
+ subject.change_row_font_size(-1, 20)
93
101
  }.to raise_error(RuntimeError)
94
102
  end
95
103
 
96
104
  it 'should create a new row if it did not exist before' do
97
- expect(@worksheet.sheet_data[11]).to be_nil
98
- @worksheet.change_row_font_size(11,20)
99
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
100
- 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)
101
109
  end
102
110
  end
103
111
 
104
112
  describe '.change_row_font_color' do
105
113
  it 'should make row and cell font colors equal to font color passed' do
106
- @worksheet.change_row_font_color(0, '0f0f0f')
107
- expect(@worksheet.get_row_font_color(0)).to eq('0f0f0f')
108
- 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')
109
117
  end
110
118
 
111
119
  it 'should raise error if hex color code not passed' do
112
120
  expect {
113
- @worksheet.change_row_font_color(0, 'G')
121
+ subject.change_row_font_color(0, 'G')
114
122
  }.to raise_error(RuntimeError)
115
123
  end
116
124
 
117
125
  it 'should raise error if hex color code includes # character' do
118
126
  expect {
119
- @worksheet.change_row_font_color(3, '#FFF000')
127
+ subject.change_row_font_color(3, '#FFF000')
120
128
  }.to raise_error(RuntimeError)
121
129
  end
122
130
 
123
131
  it 'should cause error if a negative argument is passed in' do
124
132
  expect {
125
- @worksheet.change_row_font_color(-1, '0f0f0f')
133
+ subject.change_row_font_color(-1, '0f0f0f')
126
134
  }.to raise_error(RuntimeError)
127
135
  end
128
136
 
129
137
  it 'should create a new row if it did not exist before' do
130
- expect(@worksheet.sheet_data[11]).to be_nil
131
- @worksheet.change_row_font_color(11, '0f0f0f')
132
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
133
- 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')
134
142
  end
135
143
  end
136
144
 
137
145
  describe '.change_row_italics' do
138
146
  it 'should make row and cell fonts italicized when true is passed' do
139
- @worksheet.change_row_italics(0, true)
140
- expect(@worksheet.is_row_italicized(0)).to eq(true)
141
- 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)
142
150
  end
143
151
 
144
152
  it 'should cause error if a negative argument is passed in' do
145
153
  expect {
146
- @worksheet.change_row_italics(-1, false)
154
+ subject.change_row_italics(-1, false)
147
155
  }.to raise_error(RuntimeError)
148
156
  end
149
157
 
150
158
  it 'should create a new row if it did not exist before' do
151
- expect(@worksheet.sheet_data[11]).to be_nil
152
- @worksheet.change_row_italics(11,true)
153
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
154
- 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)
155
163
  end
156
164
  end
157
165
 
158
166
  describe '.change_row_bold' do
159
167
  it 'should make row and cell fonts bolded when true is passed' do
160
- @worksheet.change_row_bold(0, true)
161
- expect(@worksheet.is_row_bolded(0)).to eq(true)
162
- 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)
163
171
  end
164
172
 
165
173
  it 'should cause error if a negative argument is passed in' do
166
174
  expect {
167
- @worksheet.change_row_bold(-1, false)
175
+ subject.change_row_bold(-1, false)
168
176
  }.to raise_error(RuntimeError)
169
177
  end
170
178
 
171
179
  it 'should create a new row if it did not exist before' do
172
- expect(@worksheet.sheet_data[11]).to be_nil
173
- @worksheet.change_row_bold(11, true)
174
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
175
- 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)
176
184
  end
177
185
  end
178
186
 
179
187
  describe '.change_row_underline' do
180
188
  it 'should make row and cell fonts underlined when true is passed' do
181
- @worksheet.change_row_underline(0, true)
182
- expect(@worksheet.is_row_underlined(0)).to eq(true)
183
- 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)
184
192
  end
185
193
 
186
194
  it 'should cause error if a negative argument is passed in' do
187
195
  expect {
188
- @worksheet.change_row_underline(-1, false)
196
+ subject.change_row_underline(-1, false)
189
197
  }.to raise_error(RuntimeError)
190
198
  end
191
199
 
192
200
  it 'should create a new row if it did not exist before' do
193
- expect(@worksheet.sheet_data[11]).to be_nil
194
- @worksheet.change_row_underline(11,true)
195
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
196
- 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)
197
205
  end
198
206
  end
199
207
 
200
208
  describe '.change_row_strikethrough' do
201
209
  it 'should make row and cell fonts struckthrough when true is passed' do
202
- @worksheet.change_row_strikethrough(0, true)
203
- expect(@worksheet.is_row_struckthrough(0)).to eq(true)
204
- 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)
205
213
  end
206
214
 
207
215
  it 'should cause error if a negative argument is passed in' do
208
216
  expect {
209
- @worksheet.change_row_strikethrough(-1, false)
217
+ subject.change_row_strikethrough(-1, false)
210
218
  }.to raise_error(RuntimeError)
211
219
  end
212
220
 
213
221
  it 'should create a new row if it did not exist before' do
214
- expect(@worksheet.sheet_data[11]).to be_nil
215
- @worksheet.change_row_strikethrough(11,true)
216
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
217
- 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)
218
226
  end
219
227
  end
220
228
 
221
229
  describe '.change_row_height' do
222
230
  it 'should make row height match number which is passed' do
223
- @worksheet.change_row_height(0,30.0002)
224
- 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)
225
233
  end
226
234
 
227
235
  it 'should make row height a number equivalent of the string passed if it is a string which is a number' do
228
- @worksheet.change_row_height(0, 30.0002)
229
- 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)
230
238
  end
231
239
 
232
240
  it 'should cause error if a negative argument is passed in' do
233
241
  expect {
234
- @worksheet.change_row_height(-1, 30)
242
+ subject.change_row_height(-1, 30)
235
243
  }.to raise_error(RuntimeError)
236
244
  end
237
245
 
238
246
  it 'should create a new row if it did not exist before' do
239
- expect(@worksheet.sheet_data[11]).to be_nil
240
- @worksheet.change_row_height(11, 30)
241
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
242
- 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)
243
251
  end
244
252
  end
245
253
 
246
254
  describe '.change_row_horizontal_alignment' do
247
255
  it 'should cause row and cells to horizontally align as specified by the passed in string' do
248
- @worksheet.change_row_horizontal_alignment(0, 'center')
249
- expect(@worksheet.get_row_alignment(0, true)).to eq('center')
250
- 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')
251
259
  end
252
260
 
253
261
  it 'should cause error if a negative argument is passed in' do
254
262
  expect {
255
- @worksheet.change_row_horizontal_alignment(-1, 'center')
263
+ subject.change_row_horizontal_alignment(-1, 'center')
256
264
  }.to raise_error(RuntimeError)
257
265
  end
258
266
 
259
267
  it 'should create a new row if it did not exist before' do
260
- expect(@worksheet.sheet_data[11]).to be_nil
261
- @worksheet.change_row_horizontal_alignment(11, 'center')
262
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
263
- 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')
264
272
  end
265
273
  end
266
274
 
267
275
  describe '.change_row_vertical_alignment' do
268
276
  it 'should cause row and cells to vertically align as specified by the passed in string' do
269
- @worksheet.change_row_vertical_alignment(0, 'center')
270
- expect(@worksheet.get_row_alignment(0, false)).to eq('center')
271
- 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')
272
280
  end
273
281
 
274
282
  it 'should cause error if a negative argument is passed in' do
275
283
  expect {
276
- @worksheet.change_row_vertical_alignment(-1, 'center')
284
+ subject.change_row_vertical_alignment(-1, 'center')
277
285
  }.to raise_error(RuntimeError)
278
286
  end
279
287
 
280
288
  it 'should create a new row if it did not exist before' do
281
- expect(@worksheet.sheet_data[11]).to be_nil
282
- @worksheet.change_row_vertical_alignment(11, 'center')
283
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
284
- 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')
285
293
  end
286
294
  end
287
295
 
288
296
  describe '.change_row_border' do
289
-
290
297
  it 'should cause error if a negative argument is passed in' do
291
298
  expect {
292
- @worksheet.change_row_border(-1, :left, 'thin')
299
+ subject.change_row_border(-1, :left, 'thin')
293
300
  }.to raise_error(RuntimeError)
294
301
  end
295
302
 
296
303
  it 'should create a new row if it did not exist before' do
297
- expect(@worksheet.sheet_data[11]).to be_nil
298
- @worksheet.change_row_border(11, :left, 'thin')
299
- expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
300
- 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')
301
308
  end
302
309
 
303
310
  it 'should cause row and cells to have border at top of specified weight' do
304
- @worksheet.change_row_border(0, :top, 'thin')
305
- expect(@worksheet.get_row_border(0, :top)).to eq('thin')
306
- 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')
307
314
  end
308
315
 
309
316
  it 'should cause row and cells to have border at left of specified weight' do
310
- @worksheet.change_row_border(0, :left, 'thin')
311
- expect(@worksheet.get_row_border(0, :left)).to eq('thin')
312
- 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')
313
320
  end
314
321
 
315
322
  it 'should cause row and cells to have border at right of specified weight' do
316
- @worksheet.change_row_border(0, :right, 'thin')
317
- expect(@worksheet.get_row_border(0, :right)).to eq('thin')
318
- 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')
319
326
  end
320
327
 
321
328
  it 'should cause row to have border at bottom of specified weight' do
322
- @worksheet.change_row_border(0, :bottom, 'thin')
323
- expect(@worksheet.get_row_border(0, :bottom)).to eq('thin')
324
- 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')
325
332
  end
326
333
 
327
334
  it 'should cause row to have border at diagonal of specified weight' do
328
- @worksheet.change_row_border(0, :diagonal, 'thin')
329
- expect(@worksheet.get_row_border(0, :diagonal)).to eq('thin')
330
- 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')
331
338
  end
332
339
  end
333
340
 
334
341
  describe '.change_column_font_name' do
335
342
  it 'should cause column and cell font names to match string passed in' do
336
- @worksheet.change_column_font_name(0, 'Arial')
337
- expect(@worksheet.get_column_font_name(0)).to eq('Arial')
338
- 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')
339
346
  end
340
347
 
341
348
  it 'should cause error if a negative argument is passed in' do
342
349
  expect {
343
- @worksheet.change_column_font_name(-1, 'Arial')
350
+ subject.change_column_font_name(-1, 'Arial')
344
351
  }.to raise_error(RuntimeError)
345
352
  end
346
353
  end
347
354
 
348
355
  describe '.change_column_font_size' do
349
356
  it 'should make column and cell font sizes equal font number passed' do
350
- @worksheet.change_column_font_size(0, 20)
351
- expect(@worksheet.get_column_font_size(0)).to eq(20)
352
- 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)
353
360
  end
354
361
 
355
362
  it 'should cause an error if a string passed' do
356
363
  expect {
357
- @worksheet.change_column_font_size(0, '20')
364
+ subject.change_column_font_size(0, '20')
358
365
  }.to raise_error(RuntimeError)
359
366
  end
360
367
 
361
368
  it 'should cause error if a negative argument is passed in' do
362
369
  expect {
363
- @worksheet.change_column_font_size(-1, 20)
370
+ subject.change_column_font_size(-1, 20)
364
371
  }.to raise_error(RuntimeError)
365
372
  end
366
373
  end
367
374
 
368
375
  describe '.change_column_font_color' do
369
376
  it 'should make column and cell font colors equal to font color passed' do
370
- @worksheet.change_column_font_color(0, '0f0f0f')
371
- expect(@worksheet.get_column_font_color(0)).to eq('0f0f0f')
372
- 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')
373
380
  end
374
381
 
375
382
  it 'should raise error if hex color code not passed' do
376
383
  expect {
377
- @worksheet.change_column_font_color(0, 'G')
384
+ subject.change_column_font_color(0, 'G')
378
385
  }.to raise_error(RuntimeError)
379
386
  end
380
387
 
381
388
  it 'should raise error if hex color code includes # character' do
382
389
  expect {
383
- @worksheet.change_column_font_color(0, '#FFF000')
390
+ subject.change_column_font_color(0, '#FFF000')
384
391
  }.to raise_error(RuntimeError)
385
392
  end
386
393
 
387
394
  it 'should cause error if a negative argument is passed in' do
388
395
  expect {
389
- @worksheet.change_column_font_color(-1, '0f0f0f')
396
+ subject.change_column_font_color(-1, '0f0f0f')
390
397
  }.to raise_error(RuntimeError)
391
398
  end
392
399
  end
393
400
 
394
401
  describe '.change_column_italics' do
395
402
  it 'should make column and cell fonts italicized when true is passed' do
396
- @worksheet.change_column_italics(0, true)
397
- expect(@worksheet.is_column_italicized(0)).to eq(true)
398
- 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)
399
406
  end
400
407
 
401
408
  it 'should cause error if a negative argument is passed in' do
402
409
  expect {
403
- @worksheet.change_column_italics(-1, false)
410
+ subject.change_column_italics(-1, false)
404
411
  }.to raise_error(RuntimeError)
405
412
  end
406
413
  end
407
414
 
408
415
  describe '.change_column_bold' do
409
416
  it 'should make column and cell fonts bolded when true is passed' do
410
- @worksheet.change_column_bold(0, true)
411
- expect(@worksheet.is_column_bolded(0)).to eq(true)
412
- 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)
413
420
  end
414
421
 
415
422
  it 'should cause error if a negative argument is passed in' do
416
423
  expect {
417
- @worksheet.change_column_bold(-1, false)
424
+ subject.change_column_bold(-1, false)
418
425
  }.to raise_error(RuntimeError)
419
426
  end
420
427
  end
421
428
 
422
429
  describe '.change_column_underline' do
423
430
  it 'should make column and cell fonts underlined when true is passed' do
424
- @worksheet.change_column_underline(0, true)
425
- expect(@worksheet.is_column_underlined(0)).to eq(true)
426
- 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)
427
434
  end
428
435
 
429
436
  it 'should cause error if a negative argument is passed in' do
430
437
  expect {
431
- @worksheet.change_column_underline(-1, false)
438
+ subject.change_column_underline(-1, false)
432
439
  }.to raise_error(RuntimeError)
433
440
  end
434
441
  end
435
442
 
436
443
  describe '.change_column_strikethrough' do
437
444
  it 'should make column and cell fonts struckthrough when true is passed' do
438
- @worksheet.change_column_strikethrough(0, true)
439
- expect(@worksheet.is_column_struckthrough(0)).to eq(true)
440
- 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)
441
448
  end
442
449
 
443
450
  it 'should cause error if a negative argument is passed in' do
444
451
  expect {
445
- @worksheet.change_column_strikethrough(-1, false)
452
+ subject.change_column_strikethrough(-1, false)
446
453
  }.to raise_error(RuntimeError)
447
454
  end
448
455
  end
449
456
 
450
457
  describe '.change_column_width_raw' do
451
458
  it 'should make column width match number which is passed' do
452
- @worksheet.change_column_width_raw(0, 30.0002)
453
- 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)
454
461
  end
455
462
 
456
463
  it 'should cause error if a negative argument is passed in' do
457
464
  expect {
458
- @worksheet.change_column_width_raw(-1, 10)
465
+ subject.change_column_width_raw(-1, 10)
459
466
  }.to raise_error(RuntimeError)
460
467
  end
461
468
  end
@@ -463,182 +470,193 @@ describe RubyXL::Worksheet do
463
470
  describe '.change_column_fill' do
464
471
  it 'should raise error if hex color code not passed' do
465
472
  expect {
466
- @worksheet.change_column_fill(0, 'G')
473
+ subject.change_column_fill(0, 'G')
467
474
  }.to raise_error(RuntimeError)
468
475
  end
469
476
 
470
477
  it 'should raise error if hex color code includes # character' do
471
478
  expect {
472
- @worksheet.change_column_fill(3, '#FFF000')
479
+ subject.change_column_fill(3, '#FFF000')
473
480
  }.to raise_error(RuntimeError)
474
481
  end
475
482
 
476
483
  it 'should make column and cell fill colors equal hex color code passed' do
477
- @worksheet.change_column_fill(0, '111111')
478
- expect(@worksheet.get_column_fill(0)).to eq('111111')
479
- 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')
480
487
  end
481
488
 
482
489
  it 'should cause error if a negative argument is passed in' do
483
490
  expect {
484
- @worksheet.change_column_fill(-1, '111111')
491
+ subject.change_column_fill(-1, '111111')
485
492
  }.to raise_error(RuntimeError)
486
493
  end
487
494
  end
488
495
 
489
496
  describe '.change_column_horizontal_alignment' do
490
497
  it 'should cause column and cell to horizontally align as specified by the passed in string' do
491
- @worksheet.change_column_horizontal_alignment(0, 'center')
492
- expect(@worksheet.get_column_alignment(0, :horizontal)).to eq('center')
493
- 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')
494
501
  end
495
502
 
496
503
  it 'should cause error if a negative argument is passed in' do
497
504
  expect {
498
- @worksheet.change_column_horizontal_alignment(-1, 'center')
505
+ subject.change_column_horizontal_alignment(-1, 'center')
499
506
  }.to raise_error(RuntimeError)
500
507
  end
501
508
  end
502
509
 
503
510
  describe '.change_column_vertical_alignment' do
504
511
  it 'should cause column and cell to vertically align as specified by the passed in string' do
505
- @worksheet.change_column_vertical_alignment(0, 'center')
506
- expect(@worksheet.get_column_alignment(0, :vertical)).to eq('center')
507
- 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')
508
515
  end
509
516
 
510
517
  it 'should cause error if a negative argument is passed in' do
511
518
  expect {
512
- @worksheet.change_column_vertical_alignment(-1, 'center')
519
+ subject.change_column_vertical_alignment(-1, 'center')
513
520
  }.to raise_error(RuntimeError)
514
521
  end
515
522
 
516
523
  it 'should set column width if column alignment is changed' do
517
524
  test_column = 2
518
- expect(@worksheet.get_column_alignment(test_column, :vertical)).to be_nil
519
- expect(@worksheet.get_column_width_raw(test_column)).to be_nil
520
- expect(@worksheet.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
521
- @worksheet.change_column_vertical_alignment(test_column, 'top')
522
- expect(@worksheet.get_column_width_raw(test_column)).not_to be_nil
523
- expect(@worksheet.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
524
- 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')
525
532
  end
526
533
  end
527
534
 
528
535
  describe '.change_column_border' do
529
536
  it 'should cause error if a negative argument is passed in' do
530
537
  expect {
531
- @worksheet.change_column_border(-1, :top, 'thin')
538
+ subject.change_column_border(-1, :top, 'thin')
532
539
  }.to raise_error(RuntimeError)
533
540
  end
534
541
 
535
542
  it 'should cause column and cells within to have border at top of specified weight' do
536
- @worksheet.change_column_border(0, :top, 'thin')
537
- expect(@worksheet.get_column_border(0, :top)).to eq('thin')
538
- 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')
539
546
  end
540
547
 
541
548
  it 'should cause column and cells within to have border at left of specified weight' do
542
- @worksheet.change_column_border(0, :left, 'thin')
543
- expect(@worksheet.get_column_border(0, :left)).to eq('thin')
544
- 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')
545
552
  end
546
553
 
547
554
  it 'should cause column and cells within to have border at right of specified weight' do
548
- @worksheet.change_column_border(0, :right, 'thin')
549
- expect(@worksheet.get_column_border(0, :right)).to eq('thin')
550
- 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')
551
558
  end
552
559
 
553
560
  it 'should cause column and cells within to have border at bottom of specified weight' do
554
- @worksheet.change_column_border(0, :bottom, 'thin')
555
- expect(@worksheet.get_column_border(0, :bottom)).to eq('thin')
556
- 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')
557
564
  end
558
565
 
559
566
  it 'should cause column and cells within to have border at diagonal of specified weight' do
560
- @worksheet.change_column_border(0, :diagonal, 'thin')
561
- expect(@worksheet.get_column_border(0, :diagonal)).to eq('thin')
562
- 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')
563
570
  end
564
571
  end
565
572
 
566
573
  describe '.merge_cells' do
567
574
  it 'should merge cells in any valid range specified by indices' do
568
- @worksheet.merge_cells(0, 0, 1, 1)
569
- 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'])
570
577
  end
571
578
  end
572
579
 
573
580
  describe '.add_cell' do
574
581
  it 'should add new cell where specified, even if a cell is already there (default)' do
575
- @worksheet.add_cell(0,0, 'TEST')
576
- expect(@worksheet[0][0].value).not_to eq(@old_cell_value)
577
- 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')
578
588
  end
579
589
 
580
590
  it 'should add a new cell below nil rows that might exist' do
581
- @worksheet.sheet_data.rows << nil << nil
582
- @worksheet.add_cell(15,0, 'TEST')
583
- 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')
584
594
  end
585
595
 
586
596
  it 'should add new cell where specified with formula, even if a cell is already there (default)' do
587
- @worksheet.add_cell(0,0, '', 'SUM(A2:A10)')
588
- expect(@worksheet[0][0].value).not_to eq(@old_cell_value)
589
- expect(@worksheet[0][0].formula).not_to eq(@old_cell_formula)
590
- expect(@worksheet[0][0].value).to eq('')
591
- 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)')
592
606
  end
593
607
 
594
608
  it 'should not overwrite when a cell is present when overwrite is specified to be false' do
595
- @worksheet.add_cell(0,0, 'TEST', 'B2',false)
596
- expect(@worksheet[0][0].value).to eq(@old_cell_value)
597
- 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)
598
616
  end
599
617
 
600
618
  it 'should still add a new cell when there is no cell to be overwritten' do
601
- @worksheet.add_cell(11,11, 'TEST', 'B2',false)
602
- expect(@worksheet[11][11].value).to eq('TEST')
603
- 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')
604
622
  end
605
623
 
606
624
  it 'should cause error if a negative argument is passed in' do
607
625
  expect {
608
- @worksheet.add_cell(-1,-1, '')
626
+ subject.add_cell(-1, -1, '')
609
627
  }.to raise_error(RuntimeError)
610
628
  end
611
629
  end
612
630
 
613
631
  describe '.delete_row' do
614
632
  it 'should delete a row at index specified, "pushing" everything else "up"' do
615
- @worksheet.delete_row(0)
616
- expect(@worksheet[0][0].value).to eq("1:0")
617
- expect(@worksheet[0][0].formula.expression.to_s).to eq("F1:0")
618
- expect(@worksheet[0][0].row).to eq(0)
619
- 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)
620
638
  end
621
639
 
622
640
  it 'should delete a row at index specified, adjusting styles for other rows' do
623
- @worksheet.change_row_font_name(1,"Courier")
624
- @worksheet.delete_row(0)
625
- 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')
626
644
  end
627
645
 
628
646
  it 'should preserve (rather than fix) formulas that reference cells in "pushed up" rows' do
629
- @worksheet.add_cell(11, 0, nil, 'SUM(A1:A10)')
630
- @worksheet.delete_row(0)
631
- 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)')
632
650
  end
633
651
 
634
652
  it 'should cause error if a negative argument is passed in' do
635
653
  expect {
636
- @worksheet.delete_row(-1)
654
+ subject.delete_row(-1)
637
655
  }.to raise_error(RuntimeError)
638
656
  end
639
657
 
640
658
  it 'should properly reindex the cells' do
641
- @worksheet.sheet_data.rows.each_with_index { |row, r|
659
+ subject.sheet_data.rows.each_with_index { |row, r|
642
660
  if (SKIP_ROW_COL == r) then
643
661
  expect(row).to be_nil
644
662
  else
@@ -660,13 +678,13 @@ describe RubyXL::Worksheet do
660
678
  # | A2 | MERGED | E2 |
661
679
  # | A3 | B3 | C3 | D3 | E3 |
662
680
  before do
663
- @worksheet.merge_cells(1, 1, 1, 3)
664
- expect(@worksheet.merged_cells.size).to eq 1
665
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D2"
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'
666
684
  end
667
685
  it 'should delete merged cell' do
668
- @worksheet.delete_row(1)
669
- expect(@worksheet.merged_cells.size).to eq 0
686
+ subject.delete_row(1)
687
+ expect(subject.merged_cells.size).to eq 0
670
688
  end
671
689
  end
672
690
  context 'merged vertical two cells' do
@@ -675,13 +693,13 @@ describe RubyXL::Worksheet do
675
693
  # | A3 | | C3 |
676
694
  # | A4 | B4 | C4 |
677
695
  before do
678
- @worksheet.merge_cells(1, 1, 2, 1)
679
- expect(@worksheet.merged_cells.size).to eq 1
680
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:B3"
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'
681
699
  end
682
700
  it 'should delete merged cell' do
683
- @worksheet.delete_row(1)
684
- expect(@worksheet.merged_cells.size).to eq 0
701
+ subject.delete_row(1)
702
+ expect(subject.merged_cells.size).to eq 0
685
703
  end
686
704
  end
687
705
 
@@ -692,9 +710,9 @@ describe RubyXL::Worksheet do
692
710
  # | A4 | | E4 |
693
711
  # | A5 | B5 | C5 | D5 | E5 |
694
712
  before do
695
- @worksheet.merge_cells(1, 1, 3, 3)
696
- expect(@worksheet.merged_cells.size).to eq 1
697
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D4"
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'
698
716
  end
699
717
 
700
718
  # | A2 | | E2 |
@@ -702,9 +720,9 @@ describe RubyXL::Worksheet do
702
720
  # | A4 | | E4 |
703
721
  # | A5 | B5 | C5 | D5 | E5 |
704
722
  it 'should updates merged cell when delete above the cell' do
705
- @worksheet.delete_row(0)
706
- expect(@worksheet.merged_cells.size).to eq 1
707
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B1:D3"
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'
708
726
  end
709
727
 
710
728
  # | A1 | B1 | C1 | D1 | E1 |
@@ -712,9 +730,9 @@ describe RubyXL::Worksheet do
712
730
  # | A4 | | E4 |
713
731
  # | A5 | B5 | C5 | D5 | E5 |
714
732
  it 'should updates merged cell when delete top of the cell' do
715
- @worksheet.delete_row(1)
716
- expect(@worksheet.merged_cells.size).to eq 1
717
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D3"
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'
718
736
  end
719
737
 
720
738
  # | A1 | B1 | C1 | D1 | E1 |
@@ -722,9 +740,9 @@ describe RubyXL::Worksheet do
722
740
  # | A4 | | E4 |
723
741
  # | A5 | B5 | C5 | D5 | E5 |
724
742
  it 'should updates merged cell when delete middle of the cell' do
725
- @worksheet.delete_row(2)
726
- expect(@worksheet.merged_cells.size).to eq 1
727
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D3"
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'
728
746
  end
729
747
 
730
748
  # | A1 | B1 | C1 | D1 | E1 |
@@ -732,9 +750,9 @@ describe RubyXL::Worksheet do
732
750
  # | A3 | | E3 |
733
751
  # | A5 | B5 | C5 | D5 | E5 |
734
752
  it 'should updates merged cell when delete bottom of the cell' do
735
- @worksheet.delete_row(3)
736
- expect(@worksheet.merged_cells.size).to eq 1
737
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D3"
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'
738
756
  end
739
757
 
740
758
  # | A1 | B1 | C1 | D1 | E1 |
@@ -742,64 +760,68 @@ describe RubyXL::Worksheet do
742
760
  # | A3 | MERGED | E3 |
743
761
  # | A4 | | E4 |
744
762
  it 'should not updates merged cell when ldelete below the cell' do
745
- @worksheet.delete_row(4)
746
- expect(@worksheet.merged_cells.size).to eq 1
747
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D4"
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'
748
766
  end
749
767
  end
750
768
  end
751
769
 
752
770
  it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
753
771
  # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
754
- @worksheet.delete_row(0)
755
- expect(@worksheet.merged_cells).to be_nil
772
+ subject.delete_row(0)
773
+ expect(subject.merged_cells).to be_nil
756
774
  end
757
775
  end
758
776
 
759
777
  describe '.insert_row' do
760
778
  it 'should insert a row at index specified, "pushing" everything else "down"' do
761
- @worksheet.insert_row(0)
762
- expect(@worksheet[0][0]).to be_nil
763
- expect(@worksheet[1][0].value).to eq(@old_cell_value)
764
- 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
765
782
 
766
- @worksheet.insert_row(7)
767
- expect(@worksheet[7][0].is_underlined).to be_nil
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)
787
+
788
+ subject.insert_row(7)
789
+ expect(subject[7][0].is_underlined).to be_nil
768
790
  end
769
791
 
770
792
  it 'should insert a row skipping nil rows that might exist' do
771
- @worksheet.sheet_data.rows << nil << nil
772
- rows = @worksheet.sheet_data.rows.size
773
- @worksheet.insert_row(rows)
774
- 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
775
797
  end
776
798
 
777
799
  it 'should insert a row at index specified, copying styles from row "above"' do
778
- @worksheet.change_row_font_name(0, 'Courier')
779
- @worksheet.insert_row(1)
780
- 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')
781
803
  end
782
804
 
783
805
  it 'should preserve (rather than fix) formulas that reference cells "pushed down" rows' do
784
- @worksheet.add_cell(5,0,nil, 'SUM(A1:A4)')
785
- @worksheet.insert_row(0)
786
- 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)')
787
809
  end
788
810
 
789
811
  it 'should cause error if a negative argument is passed in' do
790
812
  expect {
791
- @worksheet.insert_row(-1)
813
+ subject.insert_row(-1)
792
814
  }.to raise_error(RuntimeError)
793
815
  end
794
816
 
795
- it 'should expand matrix to fit argument if nonnegative' do
796
- expect(@worksheet.sheet_data.size).to eq(11)
797
- @worksheet.insert_row(11)
798
- 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)
799
821
  end
800
822
 
801
- it 'should properly reindex the cells' do
802
- @worksheet.sheet_data.rows.each_with_index { |row, r|
823
+ it 'should properly reindex the cells' do
824
+ subject.sheet_data.rows.each_with_index { |row, r|
803
825
  if (SKIP_ROW_COL == r) then
804
826
  expect(row).to be_nil
805
827
  else
@@ -821,9 +843,9 @@ describe RubyXL::Worksheet do
821
843
  # | A3 | | D3 |
822
844
  # | A4 | B4 | C4 | D4 |
823
845
  before do
824
- @worksheet.merge_cells(1, 1, 2, 2)
825
- expect(@worksheet.merged_cells.size).to eq 1
826
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C3"
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'
827
849
  end
828
850
 
829
851
  # | A1 | B1 | C1 | D1 |
@@ -832,9 +854,9 @@ describe RubyXL::Worksheet do
832
854
  # | A3 | | D3 |
833
855
  # | A4 | B4 | C4 | D4 |
834
856
  it 'should updates merged cell when insert above the cell' do
835
- @worksheet.insert_row(1)
836
- expect(@worksheet.merged_cells.size).to eq 1
837
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B3:C4"
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'
838
860
  end
839
861
 
840
862
  # | A1 | B1 | C1 | D1 |
@@ -843,9 +865,9 @@ describe RubyXL::Worksheet do
843
865
  # | A3 | | D3 |
844
866
  # | A4 | B4 | C4 | D4 |
845
867
  it 'should updates merged cell when insert into the cell' do
846
- @worksheet.insert_row(2)
847
- expect(@worksheet.merged_cells.size).to eq 1
848
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C4"
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'
849
871
  end
850
872
 
851
873
  # | A1 | B1 | C1 | D1 |
@@ -854,43 +876,43 @@ describe RubyXL::Worksheet do
854
876
  # | | | | |
855
877
  # | A4 | B4 | C4 | D4 |
856
878
  it 'should not updates merged cell when insert below the cell' do
857
- @worksheet.insert_row(3)
858
- expect(@worksheet.merged_cells.size).to eq 1
859
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C3"
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'
860
882
  end
861
883
  end
862
884
 
863
885
  it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
864
886
  # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
865
- @worksheet.insert_row(0)
866
- expect(@worksheet.merged_cells).to be_nil
887
+ subject.insert_row(0)
888
+ expect(subject.merged_cells).to be_nil
867
889
  end
868
890
  end
869
891
 
870
892
  describe '.delete_column' do
871
893
  it 'should delete a column at index specified, "pushing" everything else "left"' do
872
- @worksheet.delete_column(0)
873
- expect(@worksheet[0][0].value).to eq("0:1")
874
- expect(@worksheet[0][0].formula.expression.to_s).to eq("F0:1")
875
- 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)
876
898
  end
877
899
 
878
900
  it 'should delete a column at index specified, "pushing" styles "left"' do
879
- @worksheet.change_column_font_name(1,"Courier")
880
- @worksheet.delete_column(0)
881
- 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')
882
904
  end
883
905
 
884
906
  it 'should preserve (rather than fix) formulas that reference cells in "pushed left" columns' do
885
- @worksheet.add_cell(0,4,nil, 'SUM(A1:D1)')
886
- @worksheet.delete_column(0)
887
- 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)')
888
910
  end
889
911
 
890
912
  it 'should update cell indices after deleting the column' do
891
- @worksheet.delete_column(2)
913
+ subject.delete_column(2)
892
914
 
893
- @worksheet.sheet_data.rows.each_with_index { |row, r|
915
+ subject.sheet_data.rows.each_with_index { |row, r|
894
916
  if (SKIP_ROW_COL == r) then
895
917
  expect(row).to be_nil
896
918
  else
@@ -908,12 +930,12 @@ describe RubyXL::Worksheet do
908
930
 
909
931
  it 'should cause error if negative argument is passed in' do
910
932
  expect {
911
- @worksheet.delete_column(-1)
933
+ subject.delete_column(-1)
912
934
  }.to raise_error(RuntimeError)
913
935
  end
914
936
 
915
- it 'should properly reindex the cells' do
916
- @worksheet.sheet_data.rows.each_with_index { |row, r|
937
+ it 'should properly reindex the cells' do
938
+ subject.sheet_data.rows.each_with_index { |row, r|
917
939
  if (SKIP_ROW_COL == r) then
918
940
  expect(row).to be_nil
919
941
  else
@@ -937,13 +959,13 @@ describe RubyXL::Worksheet do
937
959
  # | A4 | | C4 |
938
960
  # | A5 | B5 | C5 |
939
961
  before do
940
- @worksheet.merge_cells(1, 1, 3, 1)
941
- expect(@worksheet.merged_cells.size).to eq 1
942
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:B4"
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'
943
965
  end
944
966
  it 'should delete merged cell' do
945
- @worksheet.delete_column(1)
946
- expect(@worksheet.merged_cells.size).to eq 0
967
+ subject.delete_column(1)
968
+ expect(subject.merged_cells.size).to eq 0
947
969
  end
948
970
  end
949
971
  context 'merged horizontal two cells' do
@@ -951,13 +973,13 @@ describe RubyXL::Worksheet do
951
973
  # | A2 | MERGED | D2 |
952
974
  # | A3 | B3 | C3 | D3 |
953
975
  before do
954
- @worksheet.merge_cells(1, 1, 1, 2)
955
- expect(@worksheet.merged_cells.size).to eq 1
956
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C2"
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'
957
979
  end
958
980
  it 'should delete merged cell' do
959
- @worksheet.delete_column(1)
960
- expect(@worksheet.merged_cells.size).to eq 0
981
+ subject.delete_column(1)
982
+ expect(subject.merged_cells.size).to eq 0
961
983
  end
962
984
  end
963
985
  context 'merged three or more columns' do
@@ -967,9 +989,9 @@ describe RubyXL::Worksheet do
967
989
  # | A4 | | E4 |
968
990
  # | A5 | B5 | C5 | D5 | E5 |
969
991
  before do
970
- @worksheet.merge_cells(1, 1, 3, 3)
971
- expect(@worksheet.merged_cells.size).to eq 1
972
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D4"
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'
973
995
  end
974
996
  # | B1 | C1 | D1 | E1 |
975
997
  # | | E2 |
@@ -977,9 +999,9 @@ describe RubyXL::Worksheet do
977
999
  # | | E4 |
978
1000
  # | B5 | C5 | D5 | E5 |
979
1001
  it 'should updates merged cell when delete before the cell' do
980
- @worksheet.delete_column(0)
981
- expect(@worksheet.merged_cells.size).to eq 1
982
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "A2:C4"
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'
983
1005
  end
984
1006
  # | A1 | C1 | D1 | E1 |
985
1007
  # | A2 | | E2 |
@@ -987,9 +1009,9 @@ describe RubyXL::Worksheet do
987
1009
  # | A4 | | E4 |
988
1010
  # | A5 | C5 | D5 | E5 |
989
1011
  it 'should updates merged cell when delete left of the cell' do
990
- @worksheet.delete_column(1)
991
- expect(@worksheet.merged_cells.size).to eq 1
992
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C4"
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'
993
1015
  end
994
1016
  # | A1 | B1 | D1 | E1 |
995
1017
  # | A2 | | E2 |
@@ -997,9 +1019,9 @@ describe RubyXL::Worksheet do
997
1019
  # | A4 | | E4 |
998
1020
  # | A5 | B5 | D5 | E5 |
999
1021
  it 'should updates merged cell when delete center of the cell' do
1000
- @worksheet.delete_column(2)
1001
- expect(@worksheet.merged_cells.size).to eq 1
1002
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C4"
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'
1003
1025
  end
1004
1026
  # | A1 | B1 | C1 | E1 |
1005
1027
  # | A2 | | E2 |
@@ -1007,9 +1029,9 @@ describe RubyXL::Worksheet do
1007
1029
  # | A4 | | E4 |
1008
1030
  # | A5 | B5 | C5 | E5 |
1009
1031
  it 'should updates merged cell when delete right of the cell' do
1010
- @worksheet.delete_column(3)
1011
- expect(@worksheet.merged_cells.size).to eq 1
1012
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C4"
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'
1013
1035
  end
1014
1036
  # | A1 | B1 | C1 | D1 |
1015
1037
  # | A2 | |
@@ -1017,49 +1039,53 @@ describe RubyXL::Worksheet do
1017
1039
  # | A4 | |
1018
1040
  # | A5 | B5 | C5 | D5 |
1019
1041
  it 'should not updates merged cell when delete after the cell' do
1020
- @worksheet.delete_column(4)
1021
- expect(@worksheet.merged_cells.size).to eq 1
1022
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D4"
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'
1023
1045
  end
1024
1046
  end
1025
1047
  end
1026
1048
 
1027
1049
  it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
1028
1050
  # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
1029
- @worksheet.delete_column(0)
1030
- expect(@worksheet.merged_cells).to be_nil
1051
+ subject.delete_column(0)
1052
+ expect(subject.merged_cells).to be_nil
1031
1053
  end
1032
1054
  end
1033
1055
 
1034
1056
  describe '.insert_column' do
1035
1057
  it 'should insert a column at index specified, "pushing" everything else "right"' do
1036
- @worksheet.insert_column(0)
1037
- expect(@worksheet[0][0]).to be_nil
1038
- expect(@worksheet[0][1].value).to eq(@old_cell_value)
1039
- 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)
1040
1066
  end
1041
1067
 
1042
1068
  it 'should insert a column at index specified, copying styles from column to "left"' do
1043
- @worksheet.change_column_font_name(0, 'Courier')
1044
- @worksheet.insert_column(1)
1045
- 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')
1046
1072
  end
1047
1073
 
1048
1074
  it 'should insert a column at 0 without copying any styles, when passed 0 as column index' do
1049
- @worksheet.change_column_font_name(0, 'Courier')
1050
- @worksheet.insert_column(0)
1051
- 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
1052
1078
  end
1053
1079
 
1054
1080
  it 'should preserve (rather than fix) formulas that reference cells in "pushed right" column' do
1055
- @worksheet.add_cell(0,5,nil, 'SUM(A1:D1)')
1056
- @worksheet.insert_column(0)
1057
- 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)')
1058
1084
  end
1059
1085
 
1060
1086
  it 'should update cell indices after deleting the column' do
1061
- @worksheet.insert_column(5)
1062
- @worksheet[0].cells.each_with_index { |cell, i|
1087
+ subject.insert_column(5)
1088
+ subject[0].cells.each_with_index { |cell, i|
1063
1089
  next if cell.nil?
1064
1090
  expect(cell.column).to eq(i)
1065
1091
  }
@@ -1067,12 +1093,12 @@ describe RubyXL::Worksheet do
1067
1093
 
1068
1094
  it 'should cause error if a negative argument is passed in' do
1069
1095
  expect {
1070
- @worksheet.insert_column(-1)
1096
+ subject.insert_column(-1)
1071
1097
  }.to raise_error(RuntimeError)
1072
1098
  end
1073
1099
 
1074
- it 'should properly reindex the cells' do
1075
- @worksheet.sheet_data.rows.each_with_index { |row, r|
1100
+ it 'should properly reindex the cells' do
1101
+ subject.sheet_data.rows.each_with_index { |row, r|
1076
1102
  if (SKIP_ROW_COL == r) then
1077
1103
  expect(row).to be_nil
1078
1104
  else
@@ -1094,9 +1120,9 @@ describe RubyXL::Worksheet do
1094
1120
  # | A3 | | D3 |
1095
1121
  # | A4 | B4 | C4 | D4 |
1096
1122
  before do
1097
- @worksheet.merge_cells(1, 1, 2, 2)
1098
- expect(@worksheet.merged_cells.size).to eq 1
1099
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C3"
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'
1100
1126
  end
1101
1127
 
1102
1128
  # | A1 | | B1 | C1 | D1 |
@@ -1104,9 +1130,9 @@ describe RubyXL::Worksheet do
1104
1130
  # | A3 | | | D3 |
1105
1131
  # | A4 | | B4 | C4 | D4 |
1106
1132
  it 'should updates merged cell when insert before the cell' do
1107
- @worksheet.insert_column(1)
1108
- expect(@worksheet.merged_cells.size).to eq 1
1109
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "C2:D3"
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'
1110
1136
  end
1111
1137
 
1112
1138
  # | A1 | B1 | | C1 | D1 |
@@ -1114,9 +1140,9 @@ describe RubyXL::Worksheet do
1114
1140
  # | A3 | | D3 |
1115
1141
  # | A4 | B4 | | C4 | D4 |
1116
1142
  it 'should updates merged cell when insert into the cell' do
1117
- @worksheet.insert_column(2)
1118
- expect(@worksheet.merged_cells.size).to eq 1
1119
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:D3"
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'
1120
1146
  end
1121
1147
 
1122
1148
  # | A1 | B1 | C1 | | D1 |
@@ -1124,37 +1150,37 @@ describe RubyXL::Worksheet do
1124
1150
  # | A3 | | | D3 |
1125
1151
  # | A4 | B4 | C4 | | D4 |
1126
1152
  it 'should not updates merged cell when insert after the cell' do
1127
- @worksheet.insert_column(3)
1128
- expect(@worksheet.merged_cells.size).to eq 1
1129
- expect(@worksheet.merged_cells.first.ref.to_s).to eq "B2:C3"
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'
1130
1156
  end
1131
1157
  end
1132
1158
 
1133
1159
  it 'should not make empty merged_cells when a worksheet does not have a merged cell' do
1134
1160
  # If a worksheet has empty merged_cells, the xlsx file has an XML error and has to repair.
1135
- @worksheet.insert_column(0)
1136
- expect(@worksheet.merged_cells).to be_nil
1161
+ subject.insert_column(0)
1162
+ expect(subject.merged_cells).to be_nil
1137
1163
  end
1138
1164
  end
1139
1165
 
1140
1166
  describe '.insert_cell' do
1141
1167
  it 'should simply add a cell if no shift argument is specified' do
1142
- @worksheet.insert_cell(0,0, 'test')
1143
- expect(@worksheet[0][0].value).to eq('test')
1144
- expect(@worksheet[0][1].value).to eq('0:1')
1145
- 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')
1146
1172
  end
1147
1173
 
1148
1174
  it 'should shift cells to the right if :right is specified' do
1149
- @worksheet.insert_cell(0, 0, 'test', nil, :right)
1150
- expect(@worksheet[0][0].value).to eq('test')
1151
- expect(@worksheet[0][1].value).to eq('0:0')
1152
- 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')
1153
1179
  end
1154
1180
 
1155
1181
  it 'should update cell indices after inserting the cell' do
1156
- @worksheet.insert_cell(0, 0, 'test', nil, :right)
1157
- @worksheet.sheet_data.rows.each_with_index { |row, r|
1182
+ subject.insert_cell(0, 0, 'test', nil, :right)
1183
+ subject.sheet_data.rows.each_with_index { |row, r|
1158
1184
  if (SKIP_ROW_COL == r) then
1159
1185
  expect(row).to be_nil
1160
1186
  else
@@ -1171,50 +1197,52 @@ describe RubyXL::Worksheet do
1171
1197
  end
1172
1198
 
1173
1199
  it 'should shift cells down if :down is specified' do
1174
- @worksheet.insert_cell(0, 0, 'test', nil, :down)
1175
- expect(@worksheet[0][0].value).to eq('test')
1176
- expect(@worksheet[0][1].value).to eq('0:1')
1177
- 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')
1178
1204
  end
1179
1205
 
1180
1206
  it 'should cause error if shift argument is specified whcih is not :right or :down' do
1181
1207
  expect {
1182
- @worksheet.insert_cell(0, 0, 'test', nil, :up)
1208
+ subject.insert_cell(0, 0, 'test', nil, :up)
1183
1209
  }.to raise_error(RuntimeError)
1184
1210
  end
1185
1211
 
1186
1212
  it 'should cause error if a negative argument is passed in' do
1187
1213
  expect {
1188
- @worksheet.insert_cell(-1, -1)
1214
+ subject.insert_cell(-1, -1)
1189
1215
  }.to raise_error(RuntimeError)
1190
1216
  end
1191
1217
  end
1192
1218
 
1193
1219
  describe '.delete_cell' do
1194
1220
  it 'should make a cell nil if no shift argument specified' do
1195
- deleted = @worksheet.delete_cell(0, 0)
1196
- expect(@worksheet[0][0]).to be_nil
1197
- 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)
1198
1226
  end
1199
1227
 
1200
1228
  it 'should return nil if a cell which is out of range is specified' do
1201
- expect(@worksheet.delete_cell(12, 12)).to be_nil
1229
+ expect(subject.delete_cell(12, 12)).to be_nil
1202
1230
  end
1203
1231
 
1204
1232
  it 'should cause error if a negative argument is passed in' do
1205
1233
  expect {
1206
- @worksheet.delete_cell(-1,-1)
1234
+ subject.delete_cell(-1, -1)
1207
1235
  }.to raise_error(RuntimeError)
1208
1236
  end
1209
1237
 
1210
1238
  it 'should shift cells to the right of the deleted cell left if :left is specified' do
1211
- @worksheet.delete_cell(0, 0, :left)
1212
- 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')
1213
1241
  end
1214
1242
 
1215
1243
  it 'should update cell indices after deleting the cell' do
1216
- @worksheet.delete_cell(4, 0, :left)
1217
- @worksheet[0].cells.each_with_index { |cell, i|
1244
+ subject.delete_cell(4, 0, :left)
1245
+ subject[0].cells.each_with_index { |cell, i|
1218
1246
  if SKIP_ROW_COL == i then
1219
1247
  expect(cell).to be_nil
1220
1248
  else
@@ -1224,492 +1252,506 @@ describe RubyXL::Worksheet do
1224
1252
  end
1225
1253
 
1226
1254
  it 'should shift cells below the deleted cell up if :up is specified' do
1227
- @worksheet.delete_cell(0,0,:up)
1228
- 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')
1229
1257
  end
1230
1258
 
1231
1259
  it 'should cause en error if an argument other than :left, :up, or nil is specified for shift' do
1232
1260
  expect {
1233
- @worksheet.delete_cell(0,0,:down)
1261
+ subject.delete_cell(0, 0, :down)
1234
1262
  }.to raise_error(RuntimeError)
1235
1263
  end
1236
1264
  end
1237
1265
 
1238
1266
  describe '.get_row_fill' do
1239
1267
  it 'should return white (ffffff) if no fill color specified for row' do
1240
- expect(@worksheet.get_row_fill(0)).to eq('ffffff')
1268
+ expect(subject.get_row_fill(0)).to eq('ffffff')
1241
1269
  end
1242
1270
 
1243
1271
  it 'should correctly reflect fill color if specified for row' do
1244
- @worksheet.change_row_fill(0, '000000')
1245
- 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')
1246
1274
  end
1247
1275
 
1248
1276
  it 'should return nil if a row which does not exist is passed in' do
1249
- expect(@worksheet.get_row_fill(11)).to be_nil
1277
+ expect(subject.get_row_fill(11)).to be_nil
1250
1278
  end
1251
1279
  end
1252
1280
 
1253
1281
  describe '.get_row_font_name' do
1254
1282
  it 'should correctly reflect font name for row' do
1255
- @worksheet.change_row_font_name(0, 'Courier')
1256
- 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')
1257
1285
  end
1258
1286
 
1259
1287
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1260
- expect(@worksheet.get_row_font_name(11)).to be_nil
1288
+ expect(subject.get_row_font_name(11)).to be_nil
1261
1289
  end
1262
1290
  end
1263
1291
 
1264
1292
  describe '.get_row_font_size' do
1265
1293
  it 'should correctly reflect font size for row' do
1266
- @worksheet.change_row_font_size(0,30)
1267
- 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)
1268
1296
  end
1269
1297
 
1270
1298
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1271
- expect(@worksheet.get_row_font_size(11)).to be_nil
1299
+ expect(subject.get_row_font_size(11)).to be_nil
1272
1300
  end
1273
1301
  end
1274
1302
 
1275
1303
  describe '.get_row_font_color' do
1276
1304
  it 'should correctly reflect font color for row' do
1277
- @worksheet.change_row_font_color(0, '0f0f0f')
1278
- 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')
1279
1307
  end
1280
1308
 
1281
1309
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1282
- expect(@worksheet.get_row_font_color(11)).to be_nil
1310
+ expect(subject.get_row_font_color(11)).to be_nil
1283
1311
  end
1284
1312
  end
1285
1313
 
1286
1314
  describe '.is_row_italicized' do
1287
1315
  it 'should correctly return whether row is italicized' do
1288
- @worksheet.change_row_italics(0, true)
1289
- 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)
1290
1318
  end
1291
1319
 
1292
1320
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1293
- expect(@worksheet.is_row_italicized(11)).to be_nil
1321
+ expect(subject.is_row_italicized(11)).to be_nil
1294
1322
  end
1295
1323
  end
1296
1324
 
1297
1325
  describe '.is_row_bolded' do
1298
1326
  it 'should correctly return whether row is bolded' do
1299
- @worksheet.change_row_bold(0, true)
1300
- 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)
1301
1329
  end
1302
1330
 
1303
1331
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1304
- expect(@worksheet.is_row_bolded(11)).to be_nil
1332
+ expect(subject.is_row_bolded(11)).to be_nil
1305
1333
  end
1306
1334
  end
1307
1335
 
1308
1336
  describe '.is_row_underlined' do
1309
1337
  it 'should correctly return whether row is underlined' do
1310
- @worksheet.change_row_underline(0, true)
1311
- 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)
1312
1340
  end
1313
1341
 
1314
1342
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1315
- expect(@worksheet.is_row_underlined(11)).to be_nil
1343
+ expect(subject.is_row_underlined(11)).to be_nil
1316
1344
  end
1317
1345
  end
1318
1346
 
1319
1347
  describe '.is_row_struckthrough' do
1320
1348
  it 'should correctly return whether row is struckthrough' do
1321
- @worksheet.change_row_strikethrough(0, true)
1322
- 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)
1323
1351
  end
1324
1352
 
1325
1353
  it 'should return nil if a (nonnegative) row which does not exist is passed in' do
1326
- expect(@worksheet.is_row_struckthrough(11)).to be_nil
1354
+ expect(subject.is_row_struckthrough(11)).to be_nil
1327
1355
  end
1328
1356
  end
1329
1357
 
1330
1358
  describe '.get_row_height' do
1331
1359
  it 'should return 13 if no height specified for row' do
1332
- expect(@worksheet.get_row_height(0)).to eq(13)
1360
+ expect(subject.get_row_height(0)).to eq(13)
1333
1361
  end
1334
1362
 
1335
1363
  it 'should correctly reflect height if specified for row' do
1336
- @worksheet.change_row_height(0, 30)
1337
- 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)
1338
1366
  end
1339
1367
 
1340
1368
  it 'should return default row height if a row which does not exist is passed in' do
1341
- expect(@worksheet.get_row_height(11)).to eq(13)
1369
+ expect(subject.get_row_height(11)).to eq(13)
1342
1370
  end
1343
1371
 
1344
1372
  it 'should cause error if a negative argument is passed in' do
1345
1373
  expect {
1346
- @worksheet.get_row_height(-1)
1374
+ subject.get_row_height(-1)
1347
1375
  }.to raise_error(RuntimeError)
1348
1376
  end
1349
1377
  end
1350
1378
 
1351
1379
  describe '.get_row_alignment' do
1352
1380
  it 'should return nil if no horizontal alignment specified for row' do
1353
- expect(@worksheet.get_row_alignment(0, true)).to be_nil
1381
+ expect(subject.get_row_alignment(0, true)).to be_nil
1354
1382
  end
1355
1383
 
1356
1384
  it 'should return nil if a row which does not exist is passed in' do
1357
- expect(@worksheet.get_row_alignment(11, true)).to be_nil
1385
+ expect(subject.get_row_alignment(11, true)).to be_nil
1358
1386
  end
1359
1387
 
1360
1388
  it 'should return correct horizontal alignment if it is set for that row' do
1361
- @worksheet.change_row_horizontal_alignment(0, 'center')
1362
- 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')
1363
1391
  end
1364
1392
 
1365
1393
  it 'should return nil if no alignment specified for row' do
1366
- expect(@worksheet.get_row_alignment(0, false)).to be_nil
1394
+ expect(subject.get_row_alignment(0, false)).to be_nil
1367
1395
  end
1368
1396
 
1369
1397
  it 'should return nil if a row which does not exist is passed in' do
1370
- expect(@worksheet.get_row_alignment(11, false)).to be_nil
1398
+ expect(subject.get_row_alignment(11, false)).to be_nil
1371
1399
  end
1372
1400
 
1373
1401
  it 'should return correct vertical alignment if it is set for that row' do
1374
- @worksheet.change_row_vertical_alignment(0, 'center')
1375
- 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')
1376
1404
  end
1377
1405
  end
1378
1406
 
1379
1407
  describe '.get_row_border' do
1380
1408
  it 'should return nil if no border is specified for that row in that direction' do
1381
- expect(@worksheet.get_row_border(0, :top)).to be_nil
1409
+ expect(subject.get_row_border(0, :top)).to be_nil
1382
1410
  end
1383
1411
 
1384
1412
  it 'should return type of border that this row has on top' do
1385
- @worksheet.change_row_border(0, :top, 'thin')
1386
- expect(@worksheet.get_row_border(0, :top)).to eq('thin')
1413
+ subject.change_row_border(0, :top, 'thin')
1414
+ expect(subject.get_row_border(0, :top)).to eq('thin')
1387
1415
  end
1388
1416
 
1389
1417
  it 'should return nil if a row which does not exist is passed in' do
1390
- expect(@worksheet.get_row_border(11, :top)).to be_nil
1418
+ expect(subject.get_row_border(11, :top)).to be_nil
1391
1419
  end
1392
1420
  end
1393
1421
 
1394
1422
  describe '.get_column_font_name' do
1395
1423
  it 'should correctly reflect font name for column' do
1396
- @worksheet.change_column_font_name(0, 'Courier')
1397
- 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')
1398
1426
  end
1399
1427
 
1400
1428
  it 'should cause error if a negative argument is passed in' do
1401
1429
  expect {
1402
- @worksheet.get_column_font_name(-1)
1430
+ subject.get_column_font_name(-1)
1403
1431
  }.to raise_error(RuntimeError)
1404
1432
  end
1405
1433
 
1406
1434
  it 'should return default font if a (nonnegative) column which does not exist is passed in' do
1407
- expect(@worksheet.get_column_font_name(11)).to eq('Verdana')
1435
+ expect(subject.get_column_font_name(11)).to eq('Verdana')
1408
1436
  end
1409
1437
  end
1410
1438
 
1411
1439
  describe '.get_column_font_size' do
1412
1440
  it 'should correctly reflect font size for column' do
1413
- @worksheet.change_column_font_size(0,30)
1414
- 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)
1415
1443
  end
1416
1444
 
1417
1445
  it 'should cause error if a negative argument is passed in' do
1418
1446
  expect {
1419
- @worksheet.get_column_font_size(-1)
1447
+ subject.get_column_font_size(-1)
1420
1448
  }.to raise_error(RuntimeError)
1421
1449
  end
1422
1450
 
1423
1451
  it 'should return default font size if a column which does not exist is passed in' do
1424
- expect(@worksheet.get_column_font_size(11)).to eq(10)
1452
+ expect(subject.get_column_font_size(11)).to eq(10)
1425
1453
  end
1426
1454
  end
1427
1455
 
1428
1456
  describe '.get_column_font_color' do
1429
1457
  it 'should correctly reflect font color for column' do
1430
- @worksheet.change_column_font_color(0, '0f0f0f')
1431
- 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')
1432
1460
  end
1433
1461
 
1434
1462
  it 'should cause error if a negative argument is passed in' do
1435
1463
  expect {
1436
- @worksheet.get_column_font_color(-1)
1464
+ subject.get_column_font_color(-1)
1437
1465
  }.to raise_error(RuntimeError)
1438
1466
  end
1439
1467
 
1440
1468
  it 'should return default color (000000) if a (nonnegative) column which does not exist is passed in' do
1441
- expect(@worksheet.get_column_font_color(11)).to eq('000000')
1469
+ expect(subject.get_column_font_color(11)).to eq('000000')
1442
1470
  end
1443
1471
 
1444
1472
  it 'should return default color (000000) if no rgb font color is specified' do
1445
- expect(@worksheet.get_column_font_color(0)).to eq('000000')
1473
+ expect(subject.get_column_font_color(0)).to eq('000000')
1446
1474
  end
1447
1475
  end
1448
1476
 
1449
1477
  describe '.is_column_italicized' do
1450
1478
  it 'should correctly return whether column is italicized' do
1451
- @worksheet.change_column_italics(0, true)
1452
- 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)
1453
1481
  end
1454
1482
 
1455
1483
  it 'should cause error if a negative argument is passed in' do
1456
1484
  expect {
1457
- @worksheet.is_column_italicized(-1)
1485
+ subject.is_column_italicized(-1)
1458
1486
  }.to raise_error(RuntimeError)
1459
1487
  end
1460
1488
 
1461
1489
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1462
- expect(@worksheet.is_column_italicized(11)).to be_nil
1490
+ expect(subject.is_column_italicized(11)).to be_nil
1463
1491
  end
1464
1492
  end
1465
1493
 
1466
1494
  describe '.is_column_bolded' do
1467
1495
  it 'should correctly return whether column is bolded' do
1468
- @worksheet.change_column_bold(0, true)
1469
- 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)
1470
1498
  end
1471
1499
 
1472
1500
  it 'should cause error if a negative argument is passed in' do
1473
1501
  expect {
1474
- @worksheet.is_column_bolded(-1)
1502
+ subject.is_column_bolded(-1)
1475
1503
  }.to raise_error(RuntimeError)
1476
1504
  end
1477
1505
 
1478
1506
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1479
- expect(@worksheet.is_column_bolded(11)).to be_nil
1507
+ expect(subject.is_column_bolded(11)).to be_nil
1480
1508
  end
1481
1509
  end
1482
1510
 
1483
1511
  describe '.is_column_underlined' do
1484
1512
  it 'should correctly return whether column is underlined' do
1485
- @worksheet.change_column_underline(0, true)
1486
- 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)
1487
1515
  end
1488
1516
 
1489
1517
  it 'should cause error if a negative argument is passed in' do
1490
1518
  expect {
1491
- @worksheet.is_column_underlined(-1)
1519
+ subject.is_column_underlined(-1)
1492
1520
  }.to raise_error(RuntimeError)
1493
1521
  end
1494
1522
 
1495
1523
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1496
- expect(@worksheet.is_column_underlined(11)).to be_nil
1524
+ expect(subject.is_column_underlined(11)).to be_nil
1497
1525
  end
1498
1526
  end
1499
1527
 
1500
1528
  describe '.is_column_struckthrough' do
1501
1529
  it 'should correctly return whether column is struckthrough' do
1502
- @worksheet.change_column_strikethrough(0, true)
1503
- 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)
1504
1532
  end
1505
1533
 
1506
1534
  it 'should cause error if a negative argument is passed in' do
1507
1535
  expect {
1508
- @worksheet.is_column_struckthrough(-1)
1536
+ subject.is_column_struckthrough(-1)
1509
1537
  }.to raise_error(RuntimeError)
1510
1538
  end
1511
1539
 
1512
1540
  it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1513
- expect(@worksheet.is_column_struckthrough(11)).to be_nil
1541
+ expect(subject.is_column_struckthrough(11)).to be_nil
1514
1542
  end
1515
1543
  end
1516
1544
 
1517
1545
  describe '.get_column_width_raw' do
1518
1546
  it 'should return nil if no width specified for column' do
1519
- expect(@worksheet.get_column_width_raw(0)).to be_nil
1547
+ expect(subject.get_column_width_raw(0)).to be_nil
1520
1548
  end
1521
1549
 
1522
1550
  it 'should correctly reflect width if specified for column' do
1523
- @worksheet.change_column_width_raw(0, 30.123)
1524
- 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)
1525
1553
  end
1526
1554
 
1527
1555
  it 'should return nil for a column that does not exist' do
1528
- expect(@worksheet.get_column_width_raw(11)).to be_nil
1556
+ expect(subject.get_column_width_raw(11)).to be_nil
1529
1557
  end
1530
1558
 
1531
1559
  it 'should cause error if a negative argument is passed in' do
1532
1560
  expect {
1533
- @worksheet.get_column_width_raw(-1)
1561
+ subject.get_column_width_raw(-1)
1534
1562
  }.to raise_error(RuntimeError)
1535
1563
  end
1536
1564
  end
1537
1565
 
1538
1566
  describe '.get_column_width' do
1539
1567
  it 'should return default width if no width specified for column' do
1540
- 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)
1541
1569
  end
1542
1570
 
1543
1571
  it 'should correctly reflect width if specified for column' do
1544
- @worksheet.change_column_width(0, 15)
1545
- 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)
1546
1574
  end
1547
1575
 
1548
1576
  it 'should return default width for a column that does not exist' do
1549
- 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)
1550
1578
  end
1551
1579
 
1552
1580
  it 'should cause error if a negative argument is passed in' do
1553
1581
  expect {
1554
- @worksheet.get_column_width(-1)
1582
+ subject.get_column_width(-1)
1555
1583
  }.to raise_error(RuntimeError)
1556
1584
  end
1557
1585
  end
1558
1586
 
1559
1587
  describe '.get_column_fill' do
1560
1588
  it 'should return white (ffffff) if no fill color specified for column' do
1561
- expect(@worksheet.get_column_fill(0)).to eq('ffffff')
1589
+ expect(subject.get_column_fill(0)).to eq('ffffff')
1562
1590
  end
1563
1591
 
1564
1592
  it 'should correctly reflect fill color if specified for column' do
1565
- @worksheet.change_column_fill(0, '000000')
1566
- 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')
1567
1595
  end
1568
1596
 
1569
1597
  it 'should return nil if a column which does not exist is passed in' do
1570
- expect(@worksheet.get_column_fill(11)).to eq('ffffff')
1598
+ expect(subject.get_column_fill(11)).to eq('ffffff')
1571
1599
  end
1572
1600
 
1573
1601
  it 'should cause error if a negative argument is passed in' do
1574
1602
  expect {
1575
- @worksheet.get_column_fill(-1)
1603
+ subject.get_column_fill(-1)
1576
1604
  }.to raise_error(RuntimeError)
1577
1605
  end
1578
1606
  end
1579
1607
 
1580
1608
  describe '.get_column_horizontal_alignment' do
1581
1609
  it 'should return nil if no alignment specified for column' do
1582
- expect(@worksheet.get_column_alignment(0, :horizontal)).to be_nil
1610
+ expect(subject.get_column_alignment(0, :horizontal)).to be_nil
1583
1611
  end
1584
1612
 
1585
1613
  it 'should return nil if a column which does not exist is passed in' do
1586
- expect(@worksheet.get_column_alignment(11, :horizontal)).to be_nil
1614
+ expect(subject.get_column_alignment(11, :horizontal)).to be_nil
1587
1615
  end
1588
1616
 
1589
1617
  it 'should cause error if a negative argument is passed in' do
1590
1618
  expect {
1591
- @worksheet.get_column_alignment(-1, :horizontal)
1619
+ subject.get_column_alignment(-1, :horizontal)
1592
1620
  }.to raise_error(RuntimeError)
1593
1621
  end
1594
1622
 
1595
1623
  it 'should return correct horizontal alignment if it is set for that column' do
1596
- @worksheet.change_column_horizontal_alignment(0, 'center')
1597
- 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')
1598
1626
  end
1599
1627
  end
1600
1628
 
1601
1629
  describe '.get_column_vertical_alignment' do
1602
1630
  it 'should return nil if no alignment specified for column' do
1603
- expect(@worksheet.get_column_alignment(0, :vertical)).to be_nil
1631
+ expect(subject.get_column_alignment(0, :vertical)).to be_nil
1604
1632
  end
1605
1633
 
1606
1634
  it 'should return nil if a column which does not exist is passed in' do
1607
- expect(@worksheet.get_column_alignment(11, :vertical)).to be_nil
1635
+ expect(subject.get_column_alignment(11, :vertical)).to be_nil
1608
1636
  end
1609
1637
 
1610
1638
  it 'should cause error if a negative argument is passed in' do
1611
1639
  expect {
1612
- @worksheet.get_column_alignment(-1, :vertical)
1640
+ subject.get_column_alignment(-1, :vertical)
1613
1641
  }.to raise_error(RuntimeError)
1614
1642
  end
1615
1643
 
1616
1644
  it 'should return correct vertical alignment if it is set for that column' do
1617
- @worksheet.change_column_vertical_alignment(0, 'center')
1618
- 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')
1619
1647
  end
1620
1648
  end
1621
1649
 
1622
1650
  describe '.get_column_border' do
1623
1651
  it 'should return nil if no border is specified for that column in that direction' do
1624
- expect(@worksheet.get_column_border(0, :diagonal)).to be_nil
1652
+ expect(subject.get_column_border(0, :diagonal)).to be_nil
1625
1653
  end
1626
1654
 
1627
1655
  it 'should return type of border that this column has on diagonal' do
1628
- @worksheet.change_column_border(0, :diagonal, 'thin')
1629
- 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')
1630
1658
  end
1631
1659
 
1632
1660
  it 'should cause error if a negative argument is passed in' do
1633
1661
  expect {
1634
- @worksheet.get_column_border(-1, :diagonal)
1662
+ subject.get_column_border(-1, :diagonal)
1635
1663
  }.to raise_error(RuntimeError)
1636
1664
  end
1637
1665
 
1638
1666
  it 'should return nil if a column which does not exist is passed in' do
1639
- expect(@worksheet.get_column_border(11, :diagonal)).to be_nil
1667
+ expect(subject.get_column_border(11, :diagonal)).to be_nil
1640
1668
  end
1641
1669
  end
1642
1670
 
1643
1671
  describe '@column_range' do
1644
1672
  it 'should properly handle range addition and modification' do
1645
1673
  # Ranges should be empty for brand new worskeet
1646
- expect(@worksheet.cols.size).to eq(0)
1674
+ expect(subject.cols.size).to eq(0)
1647
1675
 
1648
1676
  # Range should be created if the column has not been touched before
1649
- @worksheet.change_column_width(0, 30)
1650
- expect(@worksheet.get_column_width(0)).to eq(30)
1651
- 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)
1652
1680
 
1653
1681
  # Existing range should be reused
1654
- @worksheet.change_column_width(0, 20)
1655
- expect(@worksheet.get_column_width(0)).to eq(20)
1656
- 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)
1657
1685
 
1658
1686
  # Creation of the new range should not affect previously changed columns
1659
- @worksheet.change_column_width(1, 30)
1660
- expect(@worksheet.get_column_width(1)).to eq(30)
1661
- expect(@worksheet.get_column_width(0)).to eq(20)
1662
- 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)
1663
1691
 
1664
- @worksheet.cols.clear
1665
- @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
1666
1694
 
1667
- r = @worksheet.cols.locate_range(3)
1695
+ r = subject.cols.locate_range(3)
1668
1696
  expect(r.min).to eq(1)
1669
1697
  expect(r.max).to eq(9)
1670
1698
 
1671
1699
  # When a column is modified at the beginning of the range, it should shrink to the right
1672
- @worksheet.change_column_width(0, 20)
1673
- expect(@worksheet.cols.size).to eq(2)
1674
- expect(@worksheet.get_column_width(0)).to eq(20)
1675
- 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)
1676
1704
 
1677
- r = @worksheet.cols.locate_range(3)
1705
+ r = subject.cols.locate_range(3)
1678
1706
  expect(r.min).to eq(2)
1679
1707
  expect(r.max).to eq(9)
1680
1708
 
1681
1709
  # When a column is modified at the beginning of the range, it should shrink to the left
1682
- @worksheet.change_column_width(8, 30)
1683
- expect(@worksheet.cols.size).to eq(3)
1684
- 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)
1685
1713
 
1686
- r = @worksheet.cols.locate_range(3)
1714
+ r = subject.cols.locate_range(3)
1687
1715
  expect(r.min).to eq(2)
1688
1716
  expect(r.max).to eq(8)
1689
1717
 
1690
1718
  # When a column is modified in the middle of the range, it should split into two
1691
- @worksheet.change_column_width(4, 15)
1692
- expect(@worksheet.cols.size).to eq(5)
1693
- 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)
1694
1722
 
1695
- r = @worksheet.cols.locate_range(2)
1723
+ r = subject.cols.locate_range(2)
1696
1724
  expect(r.min).to eq(2)
1697
1725
  expect(r.max).to eq(4)
1698
1726
 
1699
- expect(@worksheet.get_column_width(4)).to eq(15)
1727
+ expect(subject.get_column_width(4)).to eq(15)
1700
1728
 
1701
- r = @worksheet.cols.locate_range(4)
1729
+ r = subject.cols.locate_range(4)
1702
1730
  expect(r.min).to eq(5)
1703
1731
  expect(r.max).to eq(5)
1704
1732
 
1705
- expect(@worksheet.get_column_width(5)).to eq(32)
1733
+ expect(subject.get_column_width(5)).to eq(32)
1706
1734
 
1707
- r = @worksheet.cols.locate_range(6)
1735
+ r = subject.cols.locate_range(6)
1708
1736
  expect(r.min).to eq(6)
1709
1737
  expect(r.max).to eq(8)
1738
+ end
1739
+ end
1710
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
1711
1745
  end
1712
1746
 
1713
- 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
1714
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
1715
1757
  end