rubyXL 1.2.10 → 3.4.33

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