rubyXL 3.4.12 → 3.4.25

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