rubyXL-ptr 3.3.27

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 (457) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +17 -0
  3. data/LICENSE.txt +20 -0
  4. data/README.rdoc +229 -0
  5. data/Rakefile +103 -0
  6. data/VERSION +1 -0
  7. data/lib/rubyXL.rb +12 -0
  8. data/lib/rubyXL/cell.rb +54 -0
  9. data/lib/rubyXL/convenience_methods.rb +1122 -0
  10. data/lib/rubyXL/objects/border.rb +74 -0
  11. data/lib/rubyXL/objects/calculation_chain.rb +31 -0
  12. data/lib/rubyXL/objects/cell_style.rb +65 -0
  13. data/lib/rubyXL/objects/chartsheet.rb +92 -0
  14. data/lib/rubyXL/objects/color.rb +27 -0
  15. data/lib/rubyXL/objects/column_range.rb +92 -0
  16. data/lib/rubyXL/objects/comments.rb +47 -0
  17. data/lib/rubyXL/objects/container_nodes.rb +135 -0
  18. data/lib/rubyXL/objects/content_types.rb +77 -0
  19. data/lib/rubyXL/objects/data_validation.rb +37 -0
  20. data/lib/rubyXL/objects/document_properties.rb +159 -0
  21. data/lib/rubyXL/objects/extensions.rb +40 -0
  22. data/lib/rubyXL/objects/external_links.rb +85 -0
  23. data/lib/rubyXL/objects/fill.rb +55 -0
  24. data/lib/rubyXL/objects/filters.rb +120 -0
  25. data/lib/rubyXL/objects/font.rb +48 -0
  26. data/lib/rubyXL/objects/formula.rb +24 -0
  27. data/lib/rubyXL/objects/ooxml_object.rb +460 -0
  28. data/lib/rubyXL/objects/reference.rb +110 -0
  29. data/lib/rubyXL/objects/relationships.rb +213 -0
  30. data/lib/rubyXL/objects/root.rb +86 -0
  31. data/lib/rubyXL/objects/shared_strings.rb +70 -0
  32. data/lib/rubyXL/objects/sheet_common.rb +51 -0
  33. data/lib/rubyXL/objects/sheet_data.rb +188 -0
  34. data/lib/rubyXL/objects/simple_types.rb +232 -0
  35. data/lib/rubyXL/objects/storage.rb +182 -0
  36. data/lib/rubyXL/objects/stylesheet.rb +232 -0
  37. data/lib/rubyXL/objects/text.rb +94 -0
  38. data/lib/rubyXL/objects/theme.rb +1716 -0
  39. data/lib/rubyXL/objects/workbook.rb +464 -0
  40. data/lib/rubyXL/objects/worksheet.rb +748 -0
  41. data/lib/rubyXL/parser.rb +29 -0
  42. data/lib/rubyXL/worksheet.rb +105 -0
  43. data/rdoc/README_rdoc.html +475 -0
  44. data/rdoc/RubyXL.html +598 -0
  45. data/rdoc/RubyXL/AExtension.html +223 -0
  46. data/rdoc/RubyXL/AExtensionStorageArea.html +103 -0
  47. data/rdoc/RubyXL/ActiveX.html +182 -0
  48. data/rdoc/RubyXL/ActiveXBinary.html +117 -0
  49. data/rdoc/RubyXL/AdjustHandleList.html +106 -0
  50. data/rdoc/RubyXL/Alignment.html +106 -0
  51. data/rdoc/RubyXL/AlternateContent.html +103 -0
  52. data/rdoc/RubyXL/Authors.html +106 -0
  53. data/rdoc/RubyXL/AutoFilter.html +106 -0
  54. data/rdoc/RubyXL/AutoFilterColumn.html +106 -0
  55. data/rdoc/RubyXL/BinaryImageFile.html +122 -0
  56. data/rdoc/RubyXL/BodyProperties.html +106 -0
  57. data/rdoc/RubyXL/BooleanNode.html +103 -0
  58. data/rdoc/RubyXL/BooleanValue.html +103 -0
  59. data/rdoc/RubyXL/Border.html +275 -0
  60. data/rdoc/RubyXL/BorderEdge.html +189 -0
  61. data/rdoc/RubyXL/Borders.html +157 -0
  62. data/rdoc/RubyXL/Break.html +106 -0
  63. data/rdoc/RubyXL/BreakList.html +106 -0
  64. data/rdoc/RubyXL/CT_AdjPoint2D.html +106 -0
  65. data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +106 -0
  66. data/rdoc/RubyXL/CT_AlphaModulateEffect.html +106 -0
  67. data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +106 -0
  68. data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +106 -0
  69. data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +106 -0
  70. data/rdoc/RubyXL/CT_Backdrop.html +106 -0
  71. data/rdoc/RubyXL/CT_Bevel.html +106 -0
  72. data/rdoc/RubyXL/CT_BiLevelEffect.html +106 -0
  73. data/rdoc/RubyXL/CT_BlendEffect.html +106 -0
  74. data/rdoc/RubyXL/CT_Blip.html +106 -0
  75. data/rdoc/RubyXL/CT_BlipFillProperties.html +106 -0
  76. data/rdoc/RubyXL/CT_BlurEffect.html +106 -0
  77. data/rdoc/RubyXL/CT_Camera.html +106 -0
  78. data/rdoc/RubyXL/CT_Color.html +106 -0
  79. data/rdoc/RubyXL/CT_ColorChangeEffect.html +106 -0
  80. data/rdoc/RubyXL/CT_ColorMapping.html +106 -0
  81. data/rdoc/RubyXL/CT_ColorScheme.html +106 -0
  82. data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +106 -0
  83. data/rdoc/RubyXL/CT_ConnectionSite.html +106 -0
  84. data/rdoc/RubyXL/CT_ConnectionSiteList.html +106 -0
  85. data/rdoc/RubyXL/CT_DashStop.html +106 -0
  86. data/rdoc/RubyXL/CT_DashStopList.html +106 -0
  87. data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +106 -0
  88. data/rdoc/RubyXL/CT_DuotoneEffect.html +106 -0
  89. data/rdoc/RubyXL/CT_EffectContainer.html +106 -0
  90. data/rdoc/RubyXL/CT_EffectList.html +106 -0
  91. data/rdoc/RubyXL/CT_EffectReference.html +106 -0
  92. data/rdoc/RubyXL/CT_EffectStyleItem.html +106 -0
  93. data/rdoc/RubyXL/CT_EffectStyleList.html +106 -0
  94. data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +106 -0
  95. data/rdoc/RubyXL/CT_FillEffect.html +106 -0
  96. data/rdoc/RubyXL/CT_FillOverlayEffect.html +106 -0
  97. data/rdoc/RubyXL/CT_FillStyleList.html +106 -0
  98. data/rdoc/RubyXL/CT_FlatText.html +106 -0
  99. data/rdoc/RubyXL/CT_FontCollection.html +106 -0
  100. data/rdoc/RubyXL/CT_FontReference.html +106 -0
  101. data/rdoc/RubyXL/CT_GeomGuideList.html +106 -0
  102. data/rdoc/RubyXL/CT_GlowEffect.html +106 -0
  103. data/rdoc/RubyXL/CT_GradientFillProperties.html +106 -0
  104. data/rdoc/RubyXL/CT_GradientStop.html +106 -0
  105. data/rdoc/RubyXL/CT_GradientStopList.html +106 -0
  106. data/rdoc/RubyXL/CT_HSLEffect.html +106 -0
  107. data/rdoc/RubyXL/CT_HslColor.html +106 -0
  108. data/rdoc/RubyXL/CT_Hyperlink.html +106 -0
  109. data/rdoc/RubyXL/CT_InnerShadowEffect.html +106 -0
  110. data/rdoc/RubyXL/CT_LightRig.html +106 -0
  111. data/rdoc/RubyXL/CT_LineEndProperties.html +106 -0
  112. data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +106 -0
  113. data/rdoc/RubyXL/CT_LineProperties.html +106 -0
  114. data/rdoc/RubyXL/CT_LineStyleList.html +106 -0
  115. data/rdoc/RubyXL/CT_LinearShadeProperties.html +106 -0
  116. data/rdoc/RubyXL/CT_LuminanceEffect.html +106 -0
  117. data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +106 -0
  118. data/rdoc/RubyXL/CT_OuterShadowEffect.html +106 -0
  119. data/rdoc/RubyXL/CT_Path2D.html +106 -0
  120. data/rdoc/RubyXL/CT_Path2DArcTo.html +106 -0
  121. data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +106 -0
  122. data/rdoc/RubyXL/CT_Path2DList.html +106 -0
  123. data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +106 -0
  124. data/rdoc/RubyXL/CT_Path2DTo.html +106 -0
  125. data/rdoc/RubyXL/CT_PathShadeProperties.html +106 -0
  126. data/rdoc/RubyXL/CT_PatternFillProperties.html +106 -0
  127. data/rdoc/RubyXL/CT_Point3D.html +106 -0
  128. data/rdoc/RubyXL/CT_PolarAdjustHandle.html +106 -0
  129. data/rdoc/RubyXL/CT_PresetColor.html +106 -0
  130. data/rdoc/RubyXL/CT_PresetLineDashProperties.html +106 -0
  131. data/rdoc/RubyXL/CT_PresetShadowEffect.html +106 -0
  132. data/rdoc/RubyXL/CT_PresetTextShape.html +106 -0
  133. data/rdoc/RubyXL/CT_ReflectionEffect.html +106 -0
  134. data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +106 -0
  135. data/rdoc/RubyXL/CT_RelativeRect.html +106 -0
  136. data/rdoc/RubyXL/CT_SRgbColor.html +106 -0
  137. data/rdoc/RubyXL/CT_ScRgbColor.html +106 -0
  138. data/rdoc/RubyXL/CT_Scene3D.html +106 -0
  139. data/rdoc/RubyXL/CT_SchemeColor.html +106 -0
  140. data/rdoc/RubyXL/CT_Shape3D.html +106 -0
  141. data/rdoc/RubyXL/CT_ShapeStyle.html +106 -0
  142. data/rdoc/RubyXL/CT_SoftEdgesEffect.html +106 -0
  143. data/rdoc/RubyXL/CT_SphereCoords.html +106 -0
  144. data/rdoc/RubyXL/CT_StretchInfoProperties.html +106 -0
  145. data/rdoc/RubyXL/CT_StyleMatrix.html +106 -0
  146. data/rdoc/RubyXL/CT_StyleMatrixReference.html +106 -0
  147. data/rdoc/RubyXL/CT_SupplementalFont.html +106 -0
  148. data/rdoc/RubyXL/CT_SystemColor.html +106 -0
  149. data/rdoc/RubyXL/CT_TextAutonumberBullet.html +106 -0
  150. data/rdoc/RubyXL/CT_TextBlipBullet.html +106 -0
  151. data/rdoc/RubyXL/CT_TextCharBullet.html +106 -0
  152. data/rdoc/RubyXL/CT_TextCharacterProperties.html +106 -0
  153. data/rdoc/RubyXL/CT_TextFont.html +106 -0
  154. data/rdoc/RubyXL/CT_TextListStyle.html +106 -0
  155. data/rdoc/RubyXL/CT_TextNormalAutofit.html +106 -0
  156. data/rdoc/RubyXL/CT_TextParagraphProperties.html +106 -0
  157. data/rdoc/RubyXL/CT_TextSpacing.html +106 -0
  158. data/rdoc/RubyXL/CT_TextTabStop.html +106 -0
  159. data/rdoc/RubyXL/CT_TextTabStopList.html +106 -0
  160. data/rdoc/RubyXL/CT_TileInfoProperties.html +106 -0
  161. data/rdoc/RubyXL/CT_TintEffect.html +106 -0
  162. data/rdoc/RubyXL/CT_Transform2D.html +106 -0
  163. data/rdoc/RubyXL/CT_TransformEffect.html +106 -0
  164. data/rdoc/RubyXL/CT_Vector3D.html +106 -0
  165. data/rdoc/RubyXL/CT_XYAdjustHandle.html +106 -0
  166. data/rdoc/RubyXL/CalculationChain.html +176 -0
  167. data/rdoc/RubyXL/CalculationChainCell.html +106 -0
  168. data/rdoc/RubyXL/CalculationProperties.html +106 -0
  169. data/rdoc/RubyXL/Cell.html +558 -0
  170. data/rdoc/RubyXL/CellConvenienceMethods.html +1211 -0
  171. data/rdoc/RubyXL/CellExt.html +106 -0
  172. data/rdoc/RubyXL/CellSmartTag.html +106 -0
  173. data/rdoc/RubyXL/CellSmartTagProperty.html +106 -0
  174. data/rdoc/RubyXL/CellSmartTags.html +106 -0
  175. data/rdoc/RubyXL/CellStyle.html +106 -0
  176. data/rdoc/RubyXL/CellStyleXFs.html +157 -0
  177. data/rdoc/RubyXL/CellStyles.html +157 -0
  178. data/rdoc/RubyXL/CellValue.html +158 -0
  179. data/rdoc/RubyXL/CellWatch.html +106 -0
  180. data/rdoc/RubyXL/CellWatches.html +106 -0
  181. data/rdoc/RubyXL/CellXFs.html +161 -0
  182. data/rdoc/RubyXL/ChartColorsFile.html +122 -0
  183. data/rdoc/RubyXL/ChartFile.html +189 -0
  184. data/rdoc/RubyXL/ChartStyleFile.html +122 -0
  185. data/rdoc/RubyXL/ChartUserShapesFile.html +122 -0
  186. data/rdoc/RubyXL/Chartsheet.html +260 -0
  187. data/rdoc/RubyXL/ChartsheetPageSetup.html +106 -0
  188. data/rdoc/RubyXL/ChartsheetProperties.html +106 -0
  189. data/rdoc/RubyXL/ChartsheetProtection.html +106 -0
  190. data/rdoc/RubyXL/ChartsheetView.html +106 -0
  191. data/rdoc/RubyXL/ChartsheetViews.html +106 -0
  192. data/rdoc/RubyXL/Color.html +175 -0
  193. data/rdoc/RubyXL/ColorFilter.html +106 -0
  194. data/rdoc/RubyXL/ColorScale.html +106 -0
  195. data/rdoc/RubyXL/ColorSet.html +106 -0
  196. data/rdoc/RubyXL/Colors.html +106 -0
  197. data/rdoc/RubyXL/ColumnRange.html +245 -0
  198. data/rdoc/RubyXL/ColumnRanges.html +289 -0
  199. data/rdoc/RubyXL/Comment.html +106 -0
  200. data/rdoc/RubyXL/CommentList.html +106 -0
  201. data/rdoc/RubyXL/CommentsFile.html +197 -0
  202. data/rdoc/RubyXL/ConditionalFormatValue.html +106 -0
  203. data/rdoc/RubyXL/ConditionalFormatting.html +106 -0
  204. data/rdoc/RubyXL/ConditionalFormattingRule.html +106 -0
  205. data/rdoc/RubyXL/ContentTypeDefault.html +103 -0
  206. data/rdoc/RubyXL/ContentTypeOverride.html +103 -0
  207. data/rdoc/RubyXL/ContentTypes.html +248 -0
  208. data/rdoc/RubyXL/ControlPropertiesFile.html +117 -0
  209. data/rdoc/RubyXL/CorePropertiesFile.html +474 -0
  210. data/rdoc/RubyXL/CustomColor.html +106 -0
  211. data/rdoc/RubyXL/CustomColorList.html +106 -0
  212. data/rdoc/RubyXL/CustomFilter.html +106 -0
  213. data/rdoc/RubyXL/CustomFilters.html +106 -0
  214. data/rdoc/RubyXL/CustomGeometry.html +106 -0
  215. data/rdoc/RubyXL/CustomProperties.html +106 -0
  216. data/rdoc/RubyXL/CustomPropertiesFile.html +122 -0
  217. data/rdoc/RubyXL/CustomProperty.html +106 -0
  218. data/rdoc/RubyXL/CustomSheetView.html +106 -0
  219. data/rdoc/RubyXL/CustomSheetViews.html +106 -0
  220. data/rdoc/RubyXL/CustomWorkbookView.html +106 -0
  221. data/rdoc/RubyXL/CustomWorkbookViews.html +106 -0
  222. data/rdoc/RubyXL/CustomXMLFile.html +117 -0
  223. data/rdoc/RubyXL/DXF.html +106 -0
  224. data/rdoc/RubyXL/DXFs.html +106 -0
  225. data/rdoc/RubyXL/DataBar.html +106 -0
  226. data/rdoc/RubyXL/DataConsolidate.html +106 -0
  227. data/rdoc/RubyXL/DataConsolidationReference.html +106 -0
  228. data/rdoc/RubyXL/DataConsolidationReferences.html +106 -0
  229. data/rdoc/RubyXL/DataType.html +143 -0
  230. data/rdoc/RubyXL/DataValidation.html +106 -0
  231. data/rdoc/RubyXL/DataValidations.html +106 -0
  232. data/rdoc/RubyXL/DateGroupItem.html +106 -0
  233. data/rdoc/RubyXL/DefinedName.html +106 -0
  234. data/rdoc/RubyXL/DefinedNameExt.html +106 -0
  235. data/rdoc/RubyXL/DefinedNames.html +106 -0
  236. data/rdoc/RubyXL/DefinedNamesExt.html +106 -0
  237. data/rdoc/RubyXL/DocumentPropertiesFile.html +255 -0
  238. data/rdoc/RubyXL/DrawingFile.html +188 -0
  239. data/rdoc/RubyXL/DynamicFilter.html +106 -0
  240. data/rdoc/RubyXL/EmbeddedControl.html +106 -0
  241. data/rdoc/RubyXL/EmbeddedControls.html +106 -0
  242. data/rdoc/RubyXL/Extension.html +106 -0
  243. data/rdoc/RubyXL/ExtensionStorageArea.html +106 -0
  244. data/rdoc/RubyXL/Extents.html +106 -0
  245. data/rdoc/RubyXL/ExternalBook.html +106 -0
  246. data/rdoc/RubyXL/ExternalLinksFile.html +184 -0
  247. data/rdoc/RubyXL/ExternalReference.html +106 -0
  248. data/rdoc/RubyXL/ExternalReferences.html +106 -0
  249. data/rdoc/RubyXL/ExtraColorSchemeList.html +106 -0
  250. data/rdoc/RubyXL/FieldItem.html +106 -0
  251. data/rdoc/RubyXL/FileRecoveryProperties.html +106 -0
  252. data/rdoc/RubyXL/FileSharing.html +106 -0
  253. data/rdoc/RubyXL/FileVersion.html +106 -0
  254. data/rdoc/RubyXL/Fill.html +157 -0
  255. data/rdoc/RubyXL/Fills.html +157 -0
  256. data/rdoc/RubyXL/FilterContainer.html +106 -0
  257. data/rdoc/RubyXL/FloatNode.html +103 -0
  258. data/rdoc/RubyXL/FloatValue.html +103 -0
  259. data/rdoc/RubyXL/Font.html +184 -0
  260. data/rdoc/RubyXL/FontConvenienceMethods.html +603 -0
  261. data/rdoc/RubyXL/FontScheme.html +106 -0
  262. data/rdoc/RubyXL/Fonts.html +157 -0
  263. data/rdoc/RubyXL/Formula.html +106 -0
  264. data/rdoc/RubyXL/FunctionGroup.html +106 -0
  265. data/rdoc/RubyXL/FunctionGroups.html +106 -0
  266. data/rdoc/RubyXL/GenericStorageObject.html +298 -0
  267. data/rdoc/RubyXL/GradientFill.html +106 -0
  268. data/rdoc/RubyXL/HeaderFooterSettings.html +106 -0
  269. data/rdoc/RubyXL/Hyperlink.html +106 -0
  270. data/rdoc/RubyXL/HyperlinkRelFile.html +117 -0
  271. data/rdoc/RubyXL/Hyperlinks.html +106 -0
  272. data/rdoc/RubyXL/IconFilter.html +106 -0
  273. data/rdoc/RubyXL/IconSet.html +106 -0
  274. data/rdoc/RubyXL/IgnoredError.html +106 -0
  275. data/rdoc/RubyXL/IgnoredErrors.html +106 -0
  276. data/rdoc/RubyXL/IndexedColors.html +106 -0
  277. data/rdoc/RubyXL/InputCells.html +106 -0
  278. data/rdoc/RubyXL/IntegerNode.html +103 -0
  279. data/rdoc/RubyXL/IntegerValue.html +103 -0
  280. data/rdoc/RubyXL/LegacyCell.html +181 -0
  281. data/rdoc/RubyXL/LegacyWorksheet.html +355 -0
  282. data/rdoc/RubyXL/MRUColors.html +106 -0
  283. data/rdoc/RubyXL/MacrosFile.html +122 -0
  284. data/rdoc/RubyXL/MergedCell.html +106 -0
  285. data/rdoc/RubyXL/MergedCells.html +106 -0
  286. data/rdoc/RubyXL/NumFmt.html +106 -0
  287. data/rdoc/RubyXL/NumberFormat.html +158 -0
  288. data/rdoc/RubyXL/NumberFormats.html +172 -0
  289. data/rdoc/RubyXL/OLEObject.html +106 -0
  290. data/rdoc/RubyXL/OLEObjectFile.html +122 -0
  291. data/rdoc/RubyXL/OLEObjects.html +106 -0
  292. data/rdoc/RubyXL/OLESize.html +106 -0
  293. data/rdoc/RubyXL/OOXMLContainerObject.html +394 -0
  294. data/rdoc/RubyXL/OOXMLObject.html +118 -0
  295. data/rdoc/RubyXL/OOXMLObjectClassMethods.html +532 -0
  296. data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +564 -0
  297. data/rdoc/RubyXL/OOXMLRelationshipsFile.html +603 -0
  298. data/rdoc/RubyXL/OOXMLTopLevelObject.html +384 -0
  299. data/rdoc/RubyXL/Offset.html +106 -0
  300. data/rdoc/RubyXL/OutlineProperties.html +106 -0
  301. data/rdoc/RubyXL/PageMargins.html +106 -0
  302. data/rdoc/RubyXL/PageSetup.html +106 -0
  303. data/rdoc/RubyXL/PageSetupProperties.html +106 -0
  304. data/rdoc/RubyXL/Pane.html +106 -0
  305. data/rdoc/RubyXL/Parser.html +204 -0
  306. data/rdoc/RubyXL/PatternFill.html +106 -0
  307. data/rdoc/RubyXL/PhoneticProperties.html +106 -0
  308. data/rdoc/RubyXL/PhoneticRun.html +106 -0
  309. data/rdoc/RubyXL/PivotArea.html +106 -0
  310. data/rdoc/RubyXL/PivotCache.html +106 -0
  311. data/rdoc/RubyXL/PivotCacheDefinitionFile.html +133 -0
  312. data/rdoc/RubyXL/PivotCacheRecordsFile.html +122 -0
  313. data/rdoc/RubyXL/PivotCaches.html +106 -0
  314. data/rdoc/RubyXL/PivotReference.html +106 -0
  315. data/rdoc/RubyXL/PivotReferences.html +106 -0
  316. data/rdoc/RubyXL/PivotTableFile.html +133 -0
  317. data/rdoc/RubyXL/PivotTableSelection.html +106 -0
  318. data/rdoc/RubyXL/PresetGeometry.html +106 -0
  319. data/rdoc/RubyXL/PrintOptions.html +106 -0
  320. data/rdoc/RubyXL/PrinterSettingsFile.html +122 -0
  321. data/rdoc/RubyXL/ProtectedRange.html +106 -0
  322. data/rdoc/RubyXL/ProtectedRanges.html +106 -0
  323. data/rdoc/RubyXL/Protection.html +106 -0
  324. data/rdoc/RubyXL/RID.html +103 -0
  325. data/rdoc/RubyXL/RawOOXML.html +223 -0
  326. data/rdoc/RubyXL/Reference.html +640 -0
  327. data/rdoc/RubyXL/Relationship.html +103 -0
  328. data/rdoc/RubyXL/RelationshipSupport.html +419 -0
  329. data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +148 -0
  330. data/rdoc/RubyXL/RichText.html +159 -0
  331. data/rdoc/RubyXL/RichTextRun.html +157 -0
  332. data/rdoc/RubyXL/Row.html +439 -0
  333. data/rdoc/RubyXL/RowExt.html +106 -0
  334. data/rdoc/RubyXL/RunProperties.html +106 -0
  335. data/rdoc/RubyXL/Scenario.html +106 -0
  336. data/rdoc/RubyXL/Scenarios.html +106 -0
  337. data/rdoc/RubyXL/Selection.html +165 -0
  338. data/rdoc/RubyXL/ShapeGuide.html +106 -0
  339. data/rdoc/RubyXL/ShapeTextRectangle.html +106 -0
  340. data/rdoc/RubyXL/SharedStringsTable.html +424 -0
  341. data/rdoc/RubyXL/Sheet.html +106 -0
  342. data/rdoc/RubyXL/SheetCalculationProperties.html +106 -0
  343. data/rdoc/RubyXL/SheetData.html +192 -0
  344. data/rdoc/RubyXL/SheetDataExt.html +106 -0
  345. data/rdoc/RubyXL/SheetDataSet.html +106 -0
  346. data/rdoc/RubyXL/SheetName.html +106 -0
  347. data/rdoc/RubyXL/SheetNames.html +106 -0
  348. data/rdoc/RubyXL/Sheets.html +106 -0
  349. data/rdoc/RubyXL/SlicerCacheFile.html +122 -0
  350. data/rdoc/RubyXL/SlicerFile.html +122 -0
  351. data/rdoc/RubyXL/SmartTagProperties.html +106 -0
  352. data/rdoc/RubyXL/SmartTagType.html +106 -0
  353. data/rdoc/RubyXL/SmartTagTypes.html +106 -0
  354. data/rdoc/RubyXL/SmartTags.html +106 -0
  355. data/rdoc/RubyXL/SortCondition.html +106 -0
  356. data/rdoc/RubyXL/SortState.html +106 -0
  357. data/rdoc/RubyXL/Sqref.html +197 -0
  358. data/rdoc/RubyXL/Stop.html +106 -0
  359. data/rdoc/RubyXL/StringNode.html +103 -0
  360. data/rdoc/RubyXL/StringNodeW3C.html +197 -0
  361. data/rdoc/RubyXL/StringValue.html +103 -0
  362. data/rdoc/RubyXL/Stylesheet.html +354 -0
  363. data/rdoc/RubyXL/TableFile.html +122 -0
  364. data/rdoc/RubyXL/TableParts.html +103 -0
  365. data/rdoc/RubyXL/TableStyle.html +106 -0
  366. data/rdoc/RubyXL/TableStyles.html +106 -0
  367. data/rdoc/RubyXL/Text.html +216 -0
  368. data/rdoc/RubyXL/Theme.html +535 -0
  369. data/rdoc/RubyXL/ThemeElements.html +106 -0
  370. data/rdoc/RubyXL/ThumbnailFile.html +122 -0
  371. data/rdoc/RubyXL/Top10.html +106 -0
  372. data/rdoc/RubyXL/VMLDrawingFile.html +134 -0
  373. data/rdoc/RubyXL/Variant.html +106 -0
  374. data/rdoc/RubyXL/Vector.html +161 -0
  375. data/rdoc/RubyXL/VectorValue.html +103 -0
  376. data/rdoc/RubyXL/VisualProperties.html +106 -0
  377. data/rdoc/RubyXL/WebPublishObject.html +106 -0
  378. data/rdoc/RubyXL/WebPublishObjects.html +106 -0
  379. data/rdoc/RubyXL/WebPublishingItem.html +106 -0
  380. data/rdoc/RubyXL/WebPublishingItems.html +106 -0
  381. data/rdoc/RubyXL/WebPublishingProperties.html +106 -0
  382. data/rdoc/RubyXL/Workbook.html +633 -0
  383. data/rdoc/RubyXL/WorkbookConvenienceMethods.html +1321 -0
  384. data/rdoc/RubyXL/WorkbookProperties.html +106 -0
  385. data/rdoc/RubyXL/WorkbookProtection.html +106 -0
  386. data/rdoc/RubyXL/WorkbookRoot.html +402 -0
  387. data/rdoc/RubyXL/WorkbookView.html +106 -0
  388. data/rdoc/RubyXL/WorkbookViews.html +106 -0
  389. data/rdoc/RubyXL/Worksheet.html +433 -0
  390. data/rdoc/RubyXL/WorksheetConvenienceMethods.html +2861 -0
  391. data/rdoc/RubyXL/WorksheetDimensions.html +106 -0
  392. data/rdoc/RubyXL/WorksheetFormatProperties.html +103 -0
  393. data/rdoc/RubyXL/WorksheetProperties.html +106 -0
  394. data/rdoc/RubyXL/WorksheetProtection.html +106 -0
  395. data/rdoc/RubyXL/WorksheetView.html +106 -0
  396. data/rdoc/RubyXL/WorksheetViews.html +106 -0
  397. data/rdoc/RubyXL/XF.html +106 -0
  398. data/rdoc/created.rid +38 -0
  399. data/rdoc/css/fonts.css +167 -0
  400. data/rdoc/css/rdoc.css +590 -0
  401. data/rdoc/fonts/Lato-Light.ttf +0 -0
  402. data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
  403. data/rdoc/fonts/Lato-Regular.ttf +0 -0
  404. data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
  405. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  406. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  407. data/rdoc/images/add.png +0 -0
  408. data/rdoc/images/arrow_up.png +0 -0
  409. data/rdoc/images/brick.png +0 -0
  410. data/rdoc/images/brick_link.png +0 -0
  411. data/rdoc/images/bug.png +0 -0
  412. data/rdoc/images/bullet_black.png +0 -0
  413. data/rdoc/images/bullet_toggle_minus.png +0 -0
  414. data/rdoc/images/bullet_toggle_plus.png +0 -0
  415. data/rdoc/images/date.png +0 -0
  416. data/rdoc/images/delete.png +0 -0
  417. data/rdoc/images/find.png +0 -0
  418. data/rdoc/images/loadingAnimation.gif +0 -0
  419. data/rdoc/images/macFFBgHack.png +0 -0
  420. data/rdoc/images/package.png +0 -0
  421. data/rdoc/images/page_green.png +0 -0
  422. data/rdoc/images/page_white_text.png +0 -0
  423. data/rdoc/images/page_white_width.png +0 -0
  424. data/rdoc/images/plugin.png +0 -0
  425. data/rdoc/images/ruby.png +0 -0
  426. data/rdoc/images/tag_blue.png +0 -0
  427. data/rdoc/images/tag_green.png +0 -0
  428. data/rdoc/images/transparent.png +0 -0
  429. data/rdoc/images/wrench.png +0 -0
  430. data/rdoc/images/wrench_orange.png +0 -0
  431. data/rdoc/images/zoom.png +0 -0
  432. data/rdoc/index.html +796 -0
  433. data/rdoc/js/darkfish.js +161 -0
  434. data/rdoc/js/jquery.js +4 -0
  435. data/rdoc/js/navigation.js +142 -0
  436. data/rdoc/js/navigation.js.gz +0 -0
  437. data/rdoc/js/search.js +109 -0
  438. data/rdoc/js/search_index.js +1 -0
  439. data/rdoc/js/search_index.js.gz +0 -0
  440. data/rdoc/js/searcher.js +229 -0
  441. data/rdoc/js/searcher.js.gz +0 -0
  442. data/rdoc/table_of_contents.html +2758 -0
  443. data/rubyXL.gemspec +516 -0
  444. data/spec/lib/cell_spec.rb +515 -0
  445. data/spec/lib/color_spec.rb +13 -0
  446. data/spec/lib/parser_spec.rb +118 -0
  447. data/spec/lib/reference_spec.rb +28 -0
  448. data/spec/lib/stylesheet_spec.rb +28 -0
  449. data/spec/lib/text_spec.rb +29 -0
  450. data/spec/lib/workbook_spec.rb +174 -0
  451. data/spec/lib/worksheet_spec.rb +1363 -0
  452. data/spec/spec_helper.rb +11 -0
  453. data/test/input/.gitkeep +0 -0
  454. data/test/output/.gitkeep +0 -0
  455. data/test/test_parse_write.rb +15 -0
  456. data/tmp/.gitignore +1 -0
  457. metadata +615 -0
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyXL::Color do
4
+ describe '.validate_color' do
5
+ it 'should return true if a valid hex color without a # is passed' do
6
+ expect(RubyXL::Color.validate_color('0fbCAd')).to eq(true)
7
+ end
8
+
9
+ it 'should cause an error if an invalid hex color code or one with a # is passed' do
10
+ expect {RubyXL::Color.validate_color('#G')}.to raise_error(RuntimeError)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,118 @@
1
+ require 'spec_helper'
2
+ require 'tmpdir'
3
+
4
+ describe RubyXL::Parser do
5
+
6
+ before do
7
+ @test_sheet_name = "This is a very long sheet name that should be trimmed to 31 characters for compatibility with MS Excel"
8
+ @workbook = RubyXL::Workbook.new
9
+ @workbook.add_worksheet("Test Worksheet")
10
+ @time = Time.at(Time.now.to_i) # Excel only saves times with 1-second precision.
11
+ @time2 = @time + 123456
12
+
13
+ ws = @workbook.add_worksheet("Escape Test")
14
+ ws.add_cell(0, 0, "&")
15
+ ws.add_cell(0, 1, "<")
16
+ ws.add_cell(0, 2, ">")
17
+ ws.add_cell(0, 3, "")
18
+
19
+ ws.add_cell(1, 0, "&")#TODO#.datatype = RubyXL::Cell::SHARED_STRING
20
+ ws.add_cell(1, 1, "<")#TODO#.datatype = RubyXL::Cell::SHARED_STRING
21
+ ws.add_cell(1, 2, ">")#TODO#.datatype = RubyXL::Cell::SHARED_STRING
22
+ ws.add_cell(1, 3, "")
23
+
24
+ ws.add_cell(2, 0, 0)
25
+ ws.add_cell(2, 1, 12345)
26
+ ws.add_cell(2, 2, 123.456e78)
27
+ ws.add_cell(2, 3, 123.456e-78)
28
+
29
+ ws.add_cell(3, 0, -0)
30
+ ws.add_cell(3, 1, -12345)
31
+ ws.add_cell(3, 2, -123.456e78)
32
+ ws.add_cell(3, 3, -123.456e-78)
33
+
34
+ ws[3][3].set_number_format('#.###')
35
+
36
+ @workbook.add_worksheet(@test_sheet_name)
37
+
38
+ @workbook.creator = "test creator"
39
+ @workbook.modifier = "test modifier"
40
+ @workbook.created_at = @time
41
+ @workbook.modified_at = @time2
42
+
43
+ @time_str = Time.now.to_s
44
+ @file = "rubyXL-#{$$}-#{DateTime.now.strftime('%Q')}.xlsx"
45
+ @workbook.write(@file)
46
+ end
47
+
48
+ describe '.parse' do
49
+ it 'should parse a valid Excel xlsx or xlsm workbook correctly' do
50
+ @workbook2 = RubyXL::Parser.parse(@file)
51
+
52
+ expect(@workbook2).to be_an_instance_of(::RubyXL::Workbook)
53
+
54
+ expect(@workbook2.worksheets.size).to eq(@workbook.worksheets.size)
55
+ @workbook2.worksheets.each_index { |i|
56
+ expect(@workbook2[i]).to be_an_instance_of(::RubyXL::Worksheet)
57
+ }
58
+ end
59
+
60
+ it 'should cause an error if an xlsx or xlsm workbook is not passed' do
61
+ expect {@workbook2 = RubyXL::Parser.parse("nonexistent_file.tmp")}.to raise_error(Zip::Error)
62
+ end
63
+
64
+ it 'should construct consistent number formats' do
65
+ @workbook2 = RubyXL::Parser.parse(@file)
66
+ expect(@workbook2.stylesheet.number_formats).to be_instance_of(RubyXL::NumberFormats)
67
+ expect(@workbook2.stylesheet.number_formats.size).to eq(1)
68
+ end
69
+
70
+ it 'should unescape HTML entities properly' do
71
+ @workbook2 = RubyXL::Parser.parse(@file)
72
+ expect(@workbook2["Escape Test"][0][0].value).to eq("&")
73
+ expect(@workbook2["Escape Test"][0][1].value).to eq("<")
74
+ expect(@workbook2["Escape Test"][0][2].value).to eq(">")
75
+
76
+ expect(@workbook2["Escape Test"][1][0].value).to eq("&")
77
+ expect(@workbook2["Escape Test"][1][1].value).to eq("<")
78
+ expect(@workbook2["Escape Test"][1][2].value).to eq(">")
79
+ end
80
+
81
+ it 'should parse Core properties correctly' do
82
+ @workbook2 = RubyXL::Parser.parse(@file)
83
+ expect(@workbook2.creator).to eq("test creator")
84
+ expect(@workbook2.modifier).to eq("test modifier")
85
+ expect(@workbook2.created_at).to eq(@time)
86
+ expect(@workbook2.modified_at).to eq(@time2)
87
+ end
88
+
89
+ it 'should trim excessively long sheet names on save' do
90
+ @workbook2 = RubyXL::Parser.parse(@file)
91
+ expect(@workbook2[@test_sheet_name]).to be_nil
92
+ expect(@workbook2[@test_sheet_name[0..30]]).not_to be_nil
93
+ end
94
+
95
+ end
96
+
97
+ describe 'parse_buffer' do
98
+
99
+ it 'should parse string buffer correctly' do
100
+ buffer = File.read(@file)
101
+ expect(buffer).to be_instance_of(String)
102
+ f = RubyXL::Parser.parse_buffer(buffer)
103
+ expect(f).to be_instance_of(RubyXL::Workbook)
104
+ end
105
+
106
+ it 'should parse an IO object correctly' do
107
+ io = File.open(@file)
108
+ expect(io).to be_instance_of(File)
109
+ f = RubyXL::Parser.parse_buffer(io)
110
+ expect(f).to be_instance_of(RubyXL::Workbook)
111
+ end
112
+
113
+ end
114
+
115
+ after do
116
+ File.delete(@file) if File.exist?(@file)
117
+ end
118
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyXL::Reference do
4
+
5
+ describe '.ind2ref + .ref2ind' do
6
+ it 'should correctly return the "Excel Style" description of cells when given a row/column number' do
7
+ expect(RubyXL::Reference.ind2ref(0, 26)).to eq('AA1')
8
+ expect(RubyXL::Reference.ind2ref(99, 0)).to eq('A100')
9
+ expect(RubyXL::Reference.ind2ref(0, 26)).to eq('AA1')
10
+ expect(RubyXL::Reference.ind2ref(0, 51)).to eq('AZ1')
11
+ expect(RubyXL::Reference.ind2ref(0, 52)).to eq('BA1')
12
+ expect(RubyXL::Reference.ind2ref(0, 77)).to eq('BZ1')
13
+ expect(RubyXL::Reference.ind2ref(0, 78)).to eq('CA1')
14
+ expect(RubyXL::Reference.ind2ref(0, 16383)).to eq('XFD1')
15
+ end
16
+
17
+ it 'should correctly convert back and forth between "Excel Style" and index style cell references' do
18
+ 0.upto(16383) do |n|
19
+ expect(RubyXL::Reference.ref2ind(RubyXL::Reference.ind2ref(n, 16383 - n))).to eq([ n, 16383 - n ])
20
+ end
21
+ end
22
+
23
+ it 'should return [-1, -1] if the Excel index is not well-formed' do
24
+ expect(RubyXL::Reference.ref2ind('A1B')).to eq([-1, -1])
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyXL::NumberFormat do
4
+
5
+ describe '.is_date_format?' do
6
+ it 'should return true if number format = dd// yy// mm' do
7
+ expect(RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => 'dd// yy// mm').is_date_format?()).to eq(true)
8
+ end
9
+
10
+ it 'should return true if number format = DD// YY// MM (uppercase)' do
11
+ expect(RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => 'DD// YY// MM').is_date_format?()).to eq(true)
12
+ end
13
+
14
+ it 'should return false if number format = @' do
15
+ expect(RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => '@').is_date_format?()).to eq(false)
16
+ expect(RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => 'general').is_date_format?()).to eq(false)
17
+ expect(RubyXL::NumberFormat.new(:num_fmt_id => 1, :format_code => '0.00e+00').is_date_format?()).to eq(false)
18
+ end
19
+
20
+ it 'should properly detect date formats amongst default ones' do
21
+ all_formats = RubyXL::NumberFormats::DEFAULT_NUMBER_FORMATS
22
+ id_list = all_formats.collect { |fmt| fmt.num_fmt_id if fmt.is_date_format? }.compact.sort
23
+ expect(id_list).to eq([14, 15, 16, 17, 18, 19, 20, 21, 22, 45, 46, 47])
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyXL::Text do
4
+
5
+ describe '.to_s' do
6
+
7
+ it 'should not crash processing UNICODE data' do
8
+ bytes = [ 114, 39, 95, 120, 48, 48, 56, 48, 95, 226, 132, 162, 115,
9
+ 32, 103, 105, 114, 108, 102, 114, 105, 101, 110, 100,
10
+ 39, 95, 120, 48, 48, 56, 48, 95, 226, 132, 162, 115, 32, 104, 111]
11
+
12
+ t = RubyXL::Text.new(:value => bytes.pack("c*").force_encoding('UTF-8'))
13
+
14
+ str = t.to_s
15
+
16
+ expect(str).to be
17
+ end
18
+
19
+ it 'should not escape valid XML extended UNICODE characters' do
20
+ t = RubyXL::Text.new(:value => "\u{10000}\u{10FFFF}")
21
+
22
+ xml = t.write_xml[/<t>[^<]+<\/t>/]
23
+
24
+ expect(xml).to eq("<t>\u{10000}\u{10FFFF}</t>")
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,174 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyXL::Workbook do
4
+ before do
5
+ @workbook = RubyXL::Workbook.new
6
+ @worksheet = @workbook.add_worksheet('Test Worksheet')
7
+
8
+ (0..10).each do |i|
9
+ (0..10).each do |j|
10
+ @worksheet.add_cell(i, j, "#{i}:#{j}")
11
+ end
12
+ end
13
+
14
+ @cell = @worksheet[0][0]
15
+ end
16
+
17
+ describe '.new' do
18
+ it 'should automatically create a blank worksheet named "Sheet1"' do
19
+ expect(@workbook[0]).not_to be_nil
20
+ expect(@workbook[0].sheet_name).to eq('Sheet1')
21
+ end
22
+ end
23
+
24
+ describe '[]' do
25
+ it 'should properly locate worksheet by index' do
26
+ expect(@workbook[1]).not_to be_nil
27
+ expect(@workbook[1].sheet_name).to eq('Test Worksheet')
28
+ end
29
+
30
+ it 'should properly locate worksheet by name' do
31
+ expect(@workbook['Test Worksheet']).not_to be_nil
32
+ expect(@workbook['Test Worksheet'].sheet_name).to eq('Test Worksheet')
33
+ end
34
+ end
35
+
36
+ describe '.add_worksheet' do
37
+ it 'when not given a name, it should automatically pick a name "SheetX" that is not taken yet' do
38
+ expect(@workbook['Sheet2']).to be_nil
39
+ @workbook.add_worksheet
40
+ expect(@workbook['Sheet2']).not_to be_nil
41
+ expect(@workbook['Sheet2'].sheet_name).to eq('Sheet2')
42
+ end
43
+ end
44
+
45
+ describe '.get_fill_color' do
46
+ it 'should return the fill color of a particular style attribute' do
47
+ @cell.change_fill('000000')
48
+ expect(@workbook.get_fill_color(@workbook.cell_xfs[@cell.style_index])).to eq('000000')
49
+ end
50
+
51
+ it 'should return white (ffffff) if no fill color is specified in style' do
52
+ expect(@workbook.get_fill_color(@workbook.cell_xfs[@cell.style_index])).to eq('ffffff')
53
+ end
54
+ end
55
+
56
+ describe '.application' do
57
+ it 'should contain default application string' do
58
+ expect(@workbook.application).to eq(RubyXL::Workbook::APPLICATION)
59
+ end
60
+
61
+ it 'should set application properly' do
62
+ @workbook.application = 'TEST APPLICATION'
63
+ expect(@workbook.application).to eq('TEST APPLICATION')
64
+ end
65
+ end
66
+
67
+ describe '.company' do
68
+ it 'should have default company empty' do
69
+ expect(@workbook.company).to eq('')
70
+ end
71
+
72
+ it 'should set company properly' do
73
+ @workbook.company = 'TEST COMPANY'
74
+ expect(@workbook.company).to eq('TEST COMPANY')
75
+ end
76
+ end
77
+
78
+ describe '.appversion' do
79
+ it 'should contain default appversion' do
80
+ expect(@workbook.appversion).to eq(RubyXL::Workbook::APPVERSION)
81
+ end
82
+
83
+ it 'should set appversion properly' do
84
+ @workbook.appversion = '12.34'
85
+ expect(@workbook.appversion).to eq('12.34')
86
+ end
87
+ end
88
+
89
+ describe '.creator' do
90
+ it 'should contain default creator' do
91
+ expect(@workbook.creator).to be_nil
92
+ end
93
+
94
+ it 'should set creator properly' do
95
+ @workbook.creator = 'CREATOR'
96
+ expect(@workbook.creator).to eq('CREATOR')
97
+ end
98
+ end
99
+
100
+ describe '.modifier' do
101
+ it 'should contain default modifier' do
102
+ expect(@workbook.modifier).to be_nil
103
+ end
104
+
105
+ it 'should set modifier properly' do
106
+ @workbook.modifier = 'MODIFIER'
107
+ expect(@workbook.modifier).to eq('MODIFIER')
108
+ end
109
+ end
110
+
111
+ describe '.created_at' do
112
+ it 'should contain current time by default' do
113
+ expect(@workbook.created_at).to be_a_kind_of(Time)
114
+ end
115
+
116
+ it 'should set modifier properly' do
117
+ dt = Time.at(Time.now.to_i) # Strip time of microseconds
118
+ @workbook.created_at = dt
119
+ expect(@workbook.created_at.to_time).to eq(dt)
120
+ end
121
+ end
122
+
123
+ describe '.created_at' do
124
+ it 'should contain current time by default' do
125
+ expect(@workbook.modified_at).to be_a_kind_of(Time)
126
+ end
127
+
128
+ it 'should set modifier properly' do
129
+ dt = Time.at(Time.now.to_i) # Strip time of microseconds
130
+ @workbook.modified_at = dt
131
+ expect(@workbook.modified_at.to_time).to eq(dt)
132
+ end
133
+ end
134
+
135
+ describe '.stream' do
136
+ it "It should not be confused by missing sheet_id" do
137
+ workbook = RubyXL::Workbook.new
138
+ workbook[0].sheet_id = 1
139
+ workbook.add_worksheet('Sheet2')
140
+ workbook.stream
141
+ end
142
+
143
+ it 'should raise error if bad characters are present in worksheet name' do
144
+ workbook = RubyXL::Workbook.new
145
+ workbook[0].sheet_name = 'Sheet007'
146
+ expect{workbook.stream}.to_not raise_error
147
+
148
+ '\\/*[]:?'.each_char { |char|
149
+ workbook = RubyXL::Workbook.new
150
+ workbook[0].sheet_name = "Sheet#{char}007"
151
+ expect{workbook.stream}.to raise_error(RuntimeError)
152
+ }
153
+ end
154
+ end
155
+
156
+ describe '.collect_related_objects' do
157
+ it 'should not save shared strings if there are none' do
158
+ wb = RubyXL::Workbook.new
159
+ expect(wb.root.collect_related_objects.map{ |x| x.class }.include?(::RubyXL::SharedStringsTable)).to be false
160
+ Zip::File.open_buffer(wb.stream) { |zf|
161
+ expect(zf.entries.any? { |e| e.name =~ /sharedstrings/i }).to be false
162
+ }
163
+
164
+ wb.shared_strings_container.add('test')
165
+ expect(wb.root.collect_related_objects.map{ |x| x.class }.include?(::RubyXL::SharedStringsTable)).to be true
166
+ Zip::File.open_buffer(wb.stream) { |zf|
167
+ expect(zf.entries.any? { |e| e.name =~ /sharedstrings/i }).to be true
168
+ }
169
+ end
170
+ end
171
+
172
+
173
+
174
+ end
@@ -0,0 +1,1363 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyXL::Worksheet do
4
+ before do
5
+ @workbook = RubyXL::Workbook.new
6
+ @worksheet = @workbook.add_worksheet
7
+
8
+ (0..10).each do |i|
9
+ (0..10).each do |j|
10
+ @worksheet.add_cell(i, j, "#{i}:#{j}", "F#{i}:#{j}")
11
+ end
12
+ end
13
+
14
+ @old_cell = @worksheet[0][0]
15
+ @old_cell_value = @worksheet[0][0].value.to_s
16
+ @old_cell_formula = @worksheet[0][0].formula.expression.to_s
17
+ end
18
+
19
+ describe '.change_row_fill' do
20
+ it 'should raise error if hex color code not passed' do
21
+ expect {
22
+ @worksheet.change_row_fill(0, 'G')
23
+ }.to raise_error(RuntimeError)
24
+ end
25
+
26
+ it 'should raise error if hex color code includes # character' do
27
+ expect {
28
+ @worksheet.change_row_fill(3, '#FFF000')
29
+ }.to raise_error(RuntimeError)
30
+ end
31
+
32
+ it 'should make row and cell fill colors equal hex color code passed' do
33
+ @worksheet.change_row_fill(0, '111111')
34
+ expect(@worksheet.get_row_fill(0)).to eq('111111')
35
+ expect(@worksheet[0][5].fill_color).to eq('111111')
36
+ end
37
+
38
+ it 'should cause error if a negative argument is passed in' do
39
+ expect {
40
+ @worksheet.change_row_fill(-1, '111111')
41
+ }.to raise_error(RuntimeError)
42
+ end
43
+
44
+ it 'should create a new row if it did not exist before' do
45
+ expect(@worksheet.sheet_data[11]).to be_nil
46
+ @worksheet.change_row_fill(11, '111111')
47
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
48
+ expect(@worksheet.get_row_fill(11)).to eq('111111')
49
+ end
50
+ end
51
+
52
+ describe '.change_row_font_name' do
53
+ it 'should make row and cell font names equal font name passed' do
54
+ @worksheet.change_row_font_name(0, 'Arial')
55
+ expect(@worksheet.get_row_font_name(0)).to eq('Arial')
56
+ expect(@worksheet[0][5].font_name).to eq('Arial')
57
+ end
58
+
59
+ it 'should cause error if a negative argument is passed in' do
60
+ expect {
61
+ @worksheet.change_row_font_name(-1, 'Arial')
62
+ }.to raise_error(RuntimeError)
63
+ end
64
+
65
+ it 'should create a new row if it did not exist before' do
66
+ expect(@worksheet.sheet_data[11]).to be_nil
67
+ @worksheet.change_row_font_name(11, 'Arial')
68
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
69
+ expect(@worksheet.get_row_font_name(11)).to eq("Arial")
70
+ end
71
+ end
72
+
73
+ describe '.change_row_font_size' do
74
+ it 'should make row and cell font sizes equal font number passed' do
75
+ @worksheet.change_row_font_size(0, 20)
76
+ expect(@worksheet.get_row_font_size(0)).to eq(20)
77
+ expect(@worksheet[0][5].font_size).to eq(20)
78
+ end
79
+
80
+ it 'should cause an error if a string passed' do
81
+ expect {
82
+ @worksheet.change_row_font_size(0, '20')
83
+ }.to raise_error(RuntimeError)
84
+ end
85
+
86
+ it 'should cause error if a negative argument is passed in' do
87
+ expect {
88
+ @worksheet.change_row_font_size(-1,20)
89
+ }.to raise_error(RuntimeError)
90
+ end
91
+
92
+ it 'should create a new row if it did not exist before' do
93
+ expect(@worksheet.sheet_data[11]).to be_nil
94
+ @worksheet.change_row_font_size(11,20)
95
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
96
+ expect(@worksheet.get_row_font_size(11)).to eq(20)
97
+ end
98
+ end
99
+
100
+ describe '.change_row_font_color' do
101
+ it 'should make row and cell font colors equal to font color passed' do
102
+ @worksheet.change_row_font_color(0, '0f0f0f')
103
+ expect(@worksheet.get_row_font_color(0)).to eq('0f0f0f')
104
+ expect(@worksheet[0][5].font_color).to eq('0f0f0f')
105
+ end
106
+
107
+ it 'should raise error if hex color code not passed' do
108
+ expect {
109
+ @worksheet.change_row_font_color(0, 'G')
110
+ }.to raise_error(RuntimeError)
111
+ end
112
+
113
+ it 'should raise error if hex color code includes # character' do
114
+ expect {
115
+ @worksheet.change_row_font_color(3, '#FFF000')
116
+ }.to raise_error(RuntimeError)
117
+ end
118
+
119
+ it 'should cause error if a negative argument is passed in' do
120
+ expect {
121
+ @worksheet.change_row_font_color(-1, '0f0f0f')
122
+ }.to raise_error(RuntimeError)
123
+ end
124
+
125
+ it 'should create a new row if it did not exist before' do
126
+ expect(@worksheet.sheet_data[11]).to be_nil
127
+ @worksheet.change_row_font_color(11, '0f0f0f')
128
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
129
+ expect(@worksheet.get_row_font_color(11)).to eq('0f0f0f')
130
+ end
131
+ end
132
+
133
+ describe '.change_row_italics' do
134
+ it 'should make row and cell fonts italicized when true is passed' do
135
+ @worksheet.change_row_italics(0, true)
136
+ expect(@worksheet.is_row_italicized(0)).to eq(true)
137
+ expect(@worksheet[0][5].is_italicized).to eq(true)
138
+ end
139
+
140
+ it 'should cause error if a negative argument is passed in' do
141
+ expect {
142
+ @worksheet.change_row_italics(-1, false)
143
+ }.to raise_error(RuntimeError)
144
+ end
145
+
146
+ it 'should create a new row if it did not exist before' do
147
+ expect(@worksheet.sheet_data[11]).to be_nil
148
+ @worksheet.change_row_italics(11,true)
149
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
150
+ expect(@worksheet.is_row_italicized(11)).to eq(true)
151
+ end
152
+ end
153
+
154
+ describe '.change_row_bold' do
155
+ it 'should make row and cell fonts bolded when true is passed' do
156
+ @worksheet.change_row_bold(0, true)
157
+ expect(@worksheet.is_row_bolded(0)).to eq(true)
158
+ expect(@worksheet[0][5].is_bolded).to eq(true)
159
+ end
160
+
161
+ it 'should cause error if a negative argument is passed in' do
162
+ expect {
163
+ @worksheet.change_row_bold(-1, false)
164
+ }.to raise_error(RuntimeError)
165
+ end
166
+
167
+ it 'should create a new row if it did not exist before' do
168
+ expect(@worksheet.sheet_data[11]).to be_nil
169
+ @worksheet.change_row_bold(11, true)
170
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
171
+ expect(@worksheet.is_row_bolded(11)).to eq(true)
172
+ end
173
+ end
174
+
175
+ describe '.change_row_underline' do
176
+ it 'should make row and cell fonts underlined when true is passed' do
177
+ @worksheet.change_row_underline(0, true)
178
+ expect(@worksheet.is_row_underlined(0)).to eq(true)
179
+ expect(@worksheet[0][5].is_underlined).to eq(true)
180
+ end
181
+
182
+ it 'should cause error if a negative argument is passed in' do
183
+ expect {
184
+ @worksheet.change_row_underline(-1, false)
185
+ }.to raise_error(RuntimeError)
186
+ end
187
+
188
+ it 'should create a new row if it did not exist before' do
189
+ expect(@worksheet.sheet_data[11]).to be_nil
190
+ @worksheet.change_row_underline(11,true)
191
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
192
+ expect(@worksheet.is_row_underlined(11)).to eq(true)
193
+ end
194
+ end
195
+
196
+ describe '.change_row_strikethrough' do
197
+ it 'should make row and cell fonts struckthrough when true is passed' do
198
+ @worksheet.change_row_strikethrough(0, true)
199
+ expect(@worksheet.is_row_struckthrough(0)).to eq(true)
200
+ expect(@worksheet[0][5].is_struckthrough).to eq(true)
201
+ end
202
+
203
+ it 'should cause error if a negative argument is passed in' do
204
+ expect {
205
+ @worksheet.change_row_strikethrough(-1, false)
206
+ }.to raise_error(RuntimeError)
207
+ end
208
+
209
+ it 'should create a new row if it did not exist before' do
210
+ expect(@worksheet.sheet_data[11]).to be_nil
211
+ @worksheet.change_row_strikethrough(11,true)
212
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
213
+ expect(@worksheet.is_row_struckthrough(11)).to eq(true)
214
+ end
215
+ end
216
+
217
+ describe '.change_row_height' do
218
+ it 'should make row height match number which is passed' do
219
+ @worksheet.change_row_height(0,30.0002)
220
+ expect(@worksheet.get_row_height(0)).to eq(30.0002)
221
+ end
222
+
223
+ it 'should make row height a number equivalent of the string passed if it is a string which is a number' do
224
+ @worksheet.change_row_height(0, 30.0002)
225
+ expect(@worksheet.get_row_height(0)).to eq(30.0002)
226
+ end
227
+
228
+ it 'should cause error if a negative argument is passed in' do
229
+ expect {
230
+ @worksheet.change_row_height(-1, 30)
231
+ }.to raise_error(RuntimeError)
232
+ end
233
+
234
+ it 'should create a new row if it did not exist before' do
235
+ expect(@worksheet.sheet_data[11]).to be_nil
236
+ @worksheet.change_row_height(11, 30)
237
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
238
+ expect(@worksheet.get_row_height(11)).to eq(30)
239
+ end
240
+ end
241
+
242
+ describe '.change_row_horizontal_alignment' do
243
+ it 'should cause row and cells to horizontally align as specified by the passed in string' do
244
+ @worksheet.change_row_horizontal_alignment(0, 'center')
245
+ expect(@worksheet.get_row_alignment(0, true)).to eq('center')
246
+ expect(@worksheet[0][5].horizontal_alignment).to eq('center')
247
+ end
248
+
249
+ it 'should cause error if a negative argument is passed in' do
250
+ expect {
251
+ @worksheet.change_row_horizontal_alignment(-1, 'center')
252
+ }.to raise_error(RuntimeError)
253
+ end
254
+
255
+ it 'should create a new row if it did not exist before' do
256
+ expect(@worksheet.sheet_data[11]).to be_nil
257
+ @worksheet.change_row_horizontal_alignment(11, 'center')
258
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
259
+ expect(@worksheet.get_row_alignment(11, true)).to eq('center')
260
+ end
261
+ end
262
+
263
+ describe '.change_row_vertical_alignment' do
264
+ it 'should cause row and cells to vertically align as specified by the passed in string' do
265
+ @worksheet.change_row_vertical_alignment(0, 'center')
266
+ expect(@worksheet.get_row_alignment(0, false)).to eq('center')
267
+ expect(@worksheet[0][5].vertical_alignment).to eq('center')
268
+ end
269
+
270
+ it 'should cause error if a negative argument is passed in' do
271
+ expect {
272
+ @worksheet.change_row_vertical_alignment(-1, 'center')
273
+ }.to raise_error(RuntimeError)
274
+ end
275
+
276
+ it 'should create a new row if it did not exist before' do
277
+ expect(@worksheet.sheet_data[11]).to be_nil
278
+ @worksheet.change_row_vertical_alignment(11, 'center')
279
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
280
+ expect(@worksheet.get_row_alignment(11, false)).to eq('center')
281
+ end
282
+ end
283
+
284
+ describe '.change_row_border' do
285
+
286
+ it 'should cause error if a negative argument is passed in' do
287
+ expect {
288
+ @worksheet.change_row_border(-1, :left, 'thin')
289
+ }.to raise_error(RuntimeError)
290
+ end
291
+
292
+ it 'should create a new row if it did not exist before' do
293
+ expect(@worksheet.sheet_data[11]).to be_nil
294
+ @worksheet.change_row_border(11, :left, 'thin')
295
+ expect(@worksheet.sheet_data[11]).to be_a(RubyXL::Row)
296
+ expect(@worksheet.get_row_border(11, :left)).to eq('thin')
297
+ end
298
+
299
+ it 'should cause row and cells to have border at top of specified weight' do
300
+ @worksheet.change_row_border(0, :top, 'thin')
301
+ expect(@worksheet.get_row_border(0, :top)).to eq('thin')
302
+ expect(@worksheet[0][5].get_border(:top)).to eq('thin')
303
+ end
304
+
305
+ it 'should cause row and cells to have border at left of specified weight' do
306
+ @worksheet.change_row_border(0, :left, 'thin')
307
+ expect(@worksheet.get_row_border(0, :left)).to eq('thin')
308
+ expect(@worksheet[0][5].get_border(:left)).to eq('thin')
309
+ end
310
+
311
+ it 'should cause row and cells to have border at right of specified weight' do
312
+ @worksheet.change_row_border(0, :right, 'thin')
313
+ expect(@worksheet.get_row_border(0, :right)).to eq('thin')
314
+ expect(@worksheet[0][5].get_border(:right)).to eq('thin')
315
+ end
316
+
317
+ it 'should cause row to have border at bottom of specified weight' do
318
+ @worksheet.change_row_border(0, :bottom, 'thin')
319
+ expect(@worksheet.get_row_border(0, :bottom)).to eq('thin')
320
+ expect(@worksheet[0][5].get_border(:bottom)).to eq('thin')
321
+ end
322
+
323
+ it 'should cause row to have border at diagonal of specified weight' do
324
+ @worksheet.change_row_border(0, :diagonal, 'thin')
325
+ expect(@worksheet.get_row_border(0, :diagonal)).to eq('thin')
326
+ expect(@worksheet[0][5].get_border(:diagonal)).to eq('thin')
327
+ end
328
+ end
329
+
330
+ describe '.change_column_font_name' do
331
+ it 'should cause column and cell font names to match string passed in' do
332
+ @worksheet.change_column_font_name(0, 'Arial')
333
+ expect(@worksheet.get_column_font_name(0)).to eq('Arial')
334
+ expect(@worksheet[5][0].font_name).to eq('Arial')
335
+ end
336
+
337
+ it 'should cause error if a negative argument is passed in' do
338
+ expect {
339
+ @worksheet.change_column_font_name(-1, 'Arial')
340
+ }.to raise_error(RuntimeError)
341
+ end
342
+ end
343
+
344
+ describe '.change_column_font_size' do
345
+ it 'should make column and cell font sizes equal font number passed' do
346
+ @worksheet.change_column_font_size(0, 20)
347
+ expect(@worksheet.get_column_font_size(0)).to eq(20)
348
+ expect(@worksheet[5][0].font_size).to eq(20)
349
+ end
350
+
351
+ it 'should cause an error if a string passed' do
352
+ expect {
353
+ @worksheet.change_column_font_size(0, '20')
354
+ }.to raise_error(RuntimeError)
355
+ end
356
+
357
+ it 'should cause error if a negative argument is passed in' do
358
+ expect {
359
+ @worksheet.change_column_font_size(-1, 20)
360
+ }.to raise_error(RuntimeError)
361
+ end
362
+ end
363
+
364
+ describe '.change_column_font_color' do
365
+ it 'should make column and cell font colors equal to font color passed' do
366
+ @worksheet.change_column_font_color(0, '0f0f0f')
367
+ expect(@worksheet.get_column_font_color(0)).to eq('0f0f0f')
368
+ expect(@worksheet[5][0].font_color).to eq('0f0f0f')
369
+ end
370
+
371
+ it 'should raise error if hex color code not passed' do
372
+ expect {
373
+ @worksheet.change_column_font_color(0, 'G')
374
+ }.to raise_error(RuntimeError)
375
+ end
376
+
377
+ it 'should raise error if hex color code includes # character' do
378
+ expect {
379
+ @worksheet.change_column_font_color(0, '#FFF000')
380
+ }.to raise_error(RuntimeError)
381
+ end
382
+
383
+ it 'should cause error if a negative argument is passed in' do
384
+ expect {
385
+ @worksheet.change_column_font_color(-1, '0f0f0f')
386
+ }.to raise_error(RuntimeError)
387
+ end
388
+ end
389
+
390
+ describe '.change_column_italics' do
391
+ it 'should make column and cell fonts italicized when true is passed' do
392
+ @worksheet.change_column_italics(0, true)
393
+ expect(@worksheet.is_column_italicized(0)).to eq(true)
394
+ expect(@worksheet[5][0].is_italicized).to eq(true)
395
+ end
396
+
397
+ it 'should cause error if a negative argument is passed in' do
398
+ expect {
399
+ @worksheet.change_column_italics(-1, false)
400
+ }.to raise_error(RuntimeError)
401
+ end
402
+ end
403
+
404
+ describe '.change_column_bold' do
405
+ it 'should make column and cell fonts bolded when true is passed' do
406
+ @worksheet.change_column_bold(0, true)
407
+ expect(@worksheet.is_column_bolded(0)).to eq(true)
408
+ expect(@worksheet[5][0].is_bolded).to eq(true)
409
+ end
410
+
411
+ it 'should cause error if a negative argument is passed in' do
412
+ expect {
413
+ @worksheet.change_column_bold(-1, false)
414
+ }.to raise_error(RuntimeError)
415
+ end
416
+ end
417
+
418
+ describe '.change_column_underline' do
419
+ it 'should make column and cell fonts underlined when true is passed' do
420
+ @worksheet.change_column_underline(0, true)
421
+ expect(@worksheet.is_column_underlined(0)).to eq(true)
422
+ expect(@worksheet[5][0].is_underlined).to eq(true)
423
+ end
424
+
425
+ it 'should cause error if a negative argument is passed in' do
426
+ expect {
427
+ @worksheet.change_column_underline(-1, false)
428
+ }.to raise_error(RuntimeError)
429
+ end
430
+ end
431
+
432
+ describe '.change_column_strikethrough' do
433
+ it 'should make column and cell fonts struckthrough when true is passed' do
434
+ @worksheet.change_column_strikethrough(0, true)
435
+ expect(@worksheet.is_column_struckthrough(0)).to eq(true)
436
+ expect(@worksheet[5][0].is_struckthrough).to eq(true)
437
+ end
438
+
439
+ it 'should cause error if a negative argument is passed in' do
440
+ expect {
441
+ @worksheet.change_column_strikethrough(-1, false)
442
+ }.to raise_error(RuntimeError)
443
+ end
444
+ end
445
+
446
+ describe '.change_column_width_raw' do
447
+ it 'should make column width match number which is passed' do
448
+ @worksheet.change_column_width_raw(0, 30.0002)
449
+ expect(@worksheet.get_column_width_raw(0)).to eq(30.0002)
450
+ end
451
+
452
+ it 'should cause error if a negative argument is passed in' do
453
+ expect {
454
+ @worksheet.change_column_width_raw(-1, 10)
455
+ }.to raise_error(RuntimeError)
456
+ end
457
+ end
458
+
459
+ describe '.change_column_fill' do
460
+ it 'should raise error if hex color code not passed' do
461
+ expect {
462
+ @worksheet.change_column_fill(0, 'G')
463
+ }.to raise_error(RuntimeError)
464
+ end
465
+
466
+ it 'should raise error if hex color code includes # character' do
467
+ expect {
468
+ @worksheet.change_column_fill(3, '#FFF000')
469
+ }.to raise_error(RuntimeError)
470
+ end
471
+
472
+ it 'should make column and cell fill colors equal hex color code passed' do
473
+ @worksheet.change_column_fill(0, '111111')
474
+ expect(@worksheet.get_column_fill(0)).to eq('111111')
475
+ expect(@worksheet[5][0].fill_color).to eq('111111')
476
+ end
477
+
478
+ it 'should cause error if a negative argument is passed in' do
479
+ expect {
480
+ @worksheet.change_column_fill(-1, '111111')
481
+ }.to raise_error(RuntimeError)
482
+ end
483
+ end
484
+
485
+ describe '.change_column_horizontal_alignment' do
486
+ it 'should cause column and cell to horizontally align as specified by the passed in string' do
487
+ @worksheet.change_column_horizontal_alignment(0, 'center')
488
+ expect(@worksheet.get_column_alignment(0, :horizontal)).to eq('center')
489
+ expect(@worksheet[5][0].horizontal_alignment).to eq('center')
490
+ end
491
+
492
+ it 'should cause error if a negative argument is passed in' do
493
+ expect {
494
+ @worksheet.change_column_horizontal_alignment(-1, 'center')
495
+ }.to raise_error(RuntimeError)
496
+ end
497
+ end
498
+
499
+ describe '.change_column_vertical_alignment' do
500
+ it 'should cause column and cell to vertically align as specified by the passed in string' do
501
+ @worksheet.change_column_vertical_alignment(0, 'center')
502
+ expect(@worksheet.get_column_alignment(0, :vertical)).to eq('center')
503
+ expect(@worksheet[5][0].vertical_alignment).to eq('center')
504
+ end
505
+
506
+ it 'should cause error if a negative argument is passed in' do
507
+ expect {
508
+ @worksheet.change_column_vertical_alignment(-1, 'center')
509
+ }.to raise_error(RuntimeError)
510
+ end
511
+
512
+ it 'should set column width if column alignment is changed' do
513
+ test_column = 2
514
+ expect(@worksheet.get_column_alignment(test_column, :vertical)).to be_nil
515
+ expect(@worksheet.get_column_width_raw(test_column)).to be_nil
516
+ expect(@worksheet.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
517
+ @worksheet.change_column_vertical_alignment(test_column, 'top')
518
+ expect(@worksheet.get_column_width_raw(test_column)).not_to be_nil
519
+ expect(@worksheet.get_column_width(test_column)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
520
+ expect(@worksheet.get_column_alignment(test_column, :vertical)).to eq('top')
521
+ end
522
+ end
523
+
524
+ describe '.change_column_border' do
525
+ it 'should cause error if a negative argument is passed in' do
526
+ expect {
527
+ @worksheet.change_column_border(-1, :top, 'thin')
528
+ }.to raise_error(RuntimeError)
529
+ end
530
+
531
+ it 'should cause column and cells within to have border at top of specified weight' do
532
+ @worksheet.change_column_border(0, :top, 'thin')
533
+ expect(@worksheet.get_column_border(0, :top)).to eq('thin')
534
+ expect(@worksheet[5][0].get_border(:top)).to eq('thin')
535
+ end
536
+
537
+ it 'should cause column and cells within to have border at left of specified weight' do
538
+ @worksheet.change_column_border(0, :left, 'thin')
539
+ expect(@worksheet.get_column_border(0, :left)).to eq('thin')
540
+ expect(@worksheet[5][0].get_border(:left)).to eq('thin')
541
+ end
542
+
543
+ it 'should cause column and cells within to have border at right of specified weight' do
544
+ @worksheet.change_column_border(0, :right, 'thin')
545
+ expect(@worksheet.get_column_border(0, :right)).to eq('thin')
546
+ expect(@worksheet[5][0].get_border(:right)).to eq('thin')
547
+ end
548
+
549
+ it 'should cause column and cells within to have border at bottom of specified weight' do
550
+ @worksheet.change_column_border(0, :bottom, 'thin')
551
+ expect(@worksheet.get_column_border(0, :bottom)).to eq('thin')
552
+ expect(@worksheet[5][0].get_border(:bottom)).to eq('thin')
553
+ end
554
+
555
+ it 'should cause column and cells within to have border at diagonal of specified weight' do
556
+ @worksheet.change_column_border(0, :diagonal, 'thin')
557
+ expect(@worksheet.get_column_border(0, :diagonal)).to eq('thin')
558
+ expect(@worksheet[5][0].get_border(:diagonal)).to eq('thin')
559
+ end
560
+ end
561
+
562
+ describe '.merge_cells' do
563
+ it 'should merge cells in any valid range specified by indices' do
564
+ @worksheet.merge_cells(0, 0, 1, 1)
565
+ expect(@worksheet.merged_cells.collect{ |r| r.ref.to_s }).to eq(["A1:B2"])
566
+ end
567
+ end
568
+
569
+ describe '.add_cell' do
570
+ it 'should add new cell where specified, even if a cell is already there (default)' do
571
+ @worksheet.add_cell(0,0, 'TEST')
572
+ expect(@worksheet[0][0].value).not_to eq(@old_cell_value)
573
+ expect(@worksheet[0][0].value).to eq('TEST')
574
+ end
575
+
576
+ it 'should add a new cell below nil rows that might exist' do
577
+ @worksheet.sheet_data.rows << nil << nil
578
+ @worksheet.add_cell(15,0, 'TEST')
579
+ expect(@worksheet[15][0].value).to eq('TEST')
580
+ end
581
+
582
+ it 'should add new cell where specified with formula, even if a cell is already there (default)' do
583
+ @worksheet.add_cell(0,0, '', 'SUM(A2:A10)')
584
+ expect(@worksheet[0][0].value).not_to eq(@old_cell_value)
585
+ expect(@worksheet[0][0].formula).not_to eq(@old_cell_formula)
586
+ expect(@worksheet[0][0].value).to eq('')
587
+ expect(@worksheet[0][0].formula.expression).to eq('SUM(A2:A10)')
588
+ end
589
+
590
+ it 'should not overwrite when a cell is present when overwrite is specified to be false' do
591
+ @worksheet.add_cell(0,0, 'TEST', 'B2',false)
592
+ expect(@worksheet[0][0].value).to eq(@old_cell_value)
593
+ expect(@worksheet[0][0].formula.expression.to_s).to eq(@old_cell_formula)
594
+ end
595
+
596
+ it 'should still add a new cell when there is no cell to be overwritten' do
597
+ @worksheet.add_cell(11,11, 'TEST', 'B2',false)
598
+ expect(@worksheet[11][11].value).to eq('TEST')
599
+ expect(@worksheet[11][11].formula.expression).to eq('B2')
600
+ end
601
+
602
+ it 'should cause error if a negative argument is passed in' do
603
+ expect {
604
+ @worksheet.add_cell(-1,-1, '')
605
+ }.to raise_error(RuntimeError)
606
+ end
607
+ end
608
+
609
+ describe '.delete_row' do
610
+ it 'should delete a row at index specified, "pushing" everything else "up"' do
611
+ @worksheet.delete_row(0)
612
+ expect(@worksheet[0][0].value).to eq("1:0")
613
+ expect(@worksheet[0][0].formula.expression.to_s).to eq("F1:0")
614
+ expect(@worksheet[0][0].row).to eq(0)
615
+ expect(@worksheet[0][0].column).to eq(0)
616
+ end
617
+
618
+ it 'should delete a row at index specified, adjusting styles for other rows' do
619
+ @worksheet.change_row_font_name(1,"Courier")
620
+ @worksheet.delete_row(0)
621
+ expect(@worksheet.get_row_font_name(0)).to eq("Courier")
622
+ end
623
+
624
+ it 'should preserve (rather than fix) formulas that reference cells in "pushed up" rows' do
625
+ @worksheet.add_cell(11, 0, nil, 'SUM(A1:A10)')
626
+ @worksheet.delete_row(0)
627
+ expect(@worksheet[10][0].formula.expression).to eq('SUM(A1:A10)')
628
+ end
629
+
630
+ it 'should cause error if a negative argument is passed in' do
631
+ expect {
632
+ @worksheet.delete_row(-1)
633
+ }.to raise_error(RuntimeError)
634
+ end
635
+
636
+ it 'should properly reindex the cells' do
637
+ @worksheet.sheet_data.rows.each_with_index { |row, r|
638
+ row.cells.each_with_index { |cell, c|
639
+ expect(cell.row).to eq(r)
640
+ expect(cell.column).to eq(c)
641
+ }
642
+ }
643
+ end
644
+ end
645
+
646
+ describe '.insert_row' do
647
+ it 'should insert a row at index specified, "pushing" everything else "down"' do
648
+ @worksheet.insert_row(0)
649
+ expect(@worksheet[0][0]).to be_nil
650
+ expect(@worksheet[1][0].value).to eq(@old_cell_value)
651
+ expect(@worksheet[1][0].formula.expression.to_s).to eq(@old_cell_formula)
652
+
653
+ @worksheet.insert_row(5)
654
+ expect(@worksheet[5][0].is_underlined).to be_nil
655
+ end
656
+
657
+ it 'should insert a row skipping nil rows that might exist' do
658
+ @worksheet.sheet_data.rows << nil << nil
659
+ rows = @worksheet.sheet_data.rows.size
660
+ @worksheet.insert_row(rows)
661
+ expect(@worksheet[rows - 1]).to be_nil
662
+ end
663
+
664
+ it 'should insert a row at index specified, copying styles from row "above"' do
665
+ @worksheet.change_row_font_name(0, 'Courier')
666
+ @worksheet.insert_row(1)
667
+ expect(@worksheet.get_row_font_name(1)).to eq('Courier')
668
+ end
669
+
670
+ it 'should preserve (rather than fix) formulas that reference cells "pushed down" rows' do
671
+ @worksheet.add_cell(5,0,nil, 'SUM(A1:A4)')
672
+ @worksheet.insert_row(0)
673
+ expect(@worksheet[6][0].formula.expression).to eq('SUM(A1:A4)')
674
+ end
675
+
676
+ it 'should cause error if a negative argument is passed in' do
677
+ expect {
678
+ @worksheet.insert_row(-1)
679
+ }.to raise_error(RuntimeError)
680
+ end
681
+
682
+ it 'should expand matrix to fit argument if nonnegative' do
683
+ expect(@worksheet.sheet_data.size).to eq(11)
684
+ @worksheet.insert_row(11)
685
+ expect(@worksheet.sheet_data.size).to eq(13)
686
+ end
687
+
688
+ it 'should properly reindex the cells' do
689
+ @worksheet.sheet_data.rows.each_with_index { |row, r|
690
+ row.cells.each_with_index { |cell, c|
691
+ expect(cell.row).to eq(r)
692
+ expect(cell.column).to eq(c)
693
+ }
694
+ }
695
+ end
696
+ end
697
+
698
+ describe '.delete_column' do
699
+ it 'should delete a column at index specified, "pushing" everything else "left"' do
700
+ @worksheet.delete_column(0)
701
+ expect(@worksheet[0][0].value).to eq("0:1")
702
+ expect(@worksheet[0][0].formula.expression.to_s).to eq("F0:1")
703
+ expect(@worksheet[0][0].row).to eq(0)
704
+ end
705
+
706
+ it 'should delete a column at index specified, "pushing" styles "left"' do
707
+ @worksheet.change_column_font_name(1,"Courier")
708
+ @worksheet.delete_column(0)
709
+ expect(@worksheet.get_column_font_name(0)).to eq("Courier")
710
+ end
711
+
712
+ it 'should preserve (rather than fix) formulas that reference cells in "pushed left" columns' do
713
+ @worksheet.add_cell(0,4,nil, 'SUM(A1:D1)')
714
+ @worksheet.delete_column(0)
715
+ expect(@worksheet[0][3].formula.expression).to eq('SUM(A1:D1)')
716
+ end
717
+
718
+ it 'should update cell indices after deleting the column' do
719
+ @worksheet.delete_column(2)
720
+ @worksheet[0].cells.each_with_index { |cell, i|
721
+ expect(cell.column).to eq(i)
722
+ }
723
+ end
724
+
725
+ it 'should cause error if negative argument is passed in' do
726
+ expect {
727
+ @worksheet.delete_column(-1)
728
+ }.to raise_error(RuntimeError)
729
+ end
730
+
731
+ it 'should properly reindex the cells' do
732
+ @worksheet.sheet_data.rows.each_with_index { |row, r|
733
+ row.cells.each_with_index { |cell, c|
734
+ expect(cell.row).to eq(r)
735
+ expect(cell.column).to eq(c)
736
+ }
737
+ }
738
+ end
739
+ end
740
+
741
+ describe '.insert_column' do
742
+ it 'should insert a column at index specified, "pushing" everything else "right"' do
743
+ @worksheet.insert_column(0)
744
+ expect(@worksheet[0][0]).to be_nil
745
+ expect(@worksheet[0][1].value).to eq(@old_cell_value)
746
+ expect(@worksheet[0][1].formula.expression.to_s).to eq(@old_cell_formula)
747
+ end
748
+
749
+ it 'should insert a column at index specified, copying styles from column to "left"' do
750
+ @worksheet.change_column_font_name(0, 'Courier')
751
+ @worksheet.insert_column(1)
752
+ expect(@worksheet.get_column_font_name(1)).to eq('Courier')
753
+ end
754
+
755
+ it 'should insert a column at 0 without copying any styles, when passed 0 as column index' do
756
+ @worksheet.change_column_font_name(0, 'Courier')
757
+ @worksheet.insert_column(0)
758
+ expect(@worksheet.get_column_font_name(0)).to eq('Verdana') #not courier
759
+ end
760
+
761
+ it 'should preserve (rather than fix) formulas that reference cells in "pushed right" column' do
762
+ @worksheet.add_cell(0,5,nil, 'SUM(A1:D1)')
763
+ @worksheet.insert_column(0)
764
+ expect(@worksheet[0][6].formula.expression).to eq('SUM(A1:D1)')
765
+ end
766
+
767
+ it 'should update cell indices after deleting the column' do
768
+ @worksheet.insert_column(5)
769
+ @worksheet[0].cells.each_with_index { |cell, i|
770
+ next if cell.nil?
771
+ expect(cell.column).to eq(i)
772
+ }
773
+ end
774
+
775
+ it 'should cause error if a negative argument is passed in' do
776
+ expect {
777
+ @worksheet.insert_column(-1)
778
+ }.to raise_error(RuntimeError)
779
+ end
780
+
781
+ it 'should properly reindex the cells' do
782
+ @worksheet.sheet_data.rows.each_with_index { |row, r|
783
+ row.cells.each_with_index { |cell, c|
784
+ expect(cell.row).to eq(r)
785
+ expect(cell.column).to eq(c)
786
+ }
787
+ }
788
+ end
789
+ end
790
+
791
+ describe '.insert_cell' do
792
+ it 'should simply add a cell if no shift argument is specified' do
793
+ @worksheet.insert_cell(0,0, 'test')
794
+ expect(@worksheet[0][0].value).to eq('test')
795
+ expect(@worksheet[0][1].value).to eq('0:1')
796
+ expect(@worksheet[1][0].value).to eq('1:0')
797
+ end
798
+
799
+ it 'should shift cells to the right if :right is specified' do
800
+ @worksheet.insert_cell(0, 0, 'test', nil, :right)
801
+ expect(@worksheet[0][0].value).to eq('test')
802
+ expect(@worksheet[0][1].value).to eq('0:0')
803
+ expect(@worksheet[1][0].value).to eq('1:0')
804
+ end
805
+
806
+ it 'should update cell indices after inserting the cell' do
807
+ @worksheet.insert_cell(0, 0, 'test', nil, :right)
808
+ @worksheet[0].cells.each_with_index { |cell, i|
809
+ expect(cell.column).to eq(i)
810
+ }
811
+ end
812
+
813
+ it 'should shift cells down if :down is specified' do
814
+ @worksheet.insert_cell(0, 0, 'test', nil, :down)
815
+ expect(@worksheet[0][0].value).to eq('test')
816
+ expect(@worksheet[0][1].value).to eq('0:1')
817
+ expect(@worksheet[1][0].value).to eq('0:0')
818
+ end
819
+
820
+ it 'should cause error if shift argument is specified whcih is not :right or :down' do
821
+ expect {
822
+ @worksheet.insert_cell(0, 0, 'test', nil, :up)
823
+ }.to raise_error(RuntimeError)
824
+ end
825
+
826
+ it 'should cause error if a negative argument is passed in' do
827
+ expect {
828
+ @worksheet.insert_cell(-1, -1)
829
+ }.to raise_error(RuntimeError)
830
+ end
831
+ end
832
+
833
+ describe '.delete_cell' do
834
+ it 'should make a cell nil if no shift argument specified' do
835
+ deleted = @worksheet.delete_cell(0, 0)
836
+ expect(@worksheet[0][0]).to be_nil
837
+ expect(@old_cell.inspect).to eq(deleted.inspect)
838
+ end
839
+
840
+ it 'should return nil if a cell which is out of range is specified' do
841
+ expect(@worksheet.delete_cell(12, 12)).to be_nil
842
+ end
843
+
844
+ it 'should cause error if a negative argument is passed in' do
845
+ expect {
846
+ @worksheet.delete_cell(-1,-1)
847
+ }.to raise_error(RuntimeError)
848
+ end
849
+
850
+ it 'should shift cells to the right of the deleted cell left if :left is specified' do
851
+ @worksheet.delete_cell(0, 0, :left)
852
+ expect(@worksheet[0][0].value).to eq('0:1')
853
+ end
854
+
855
+ it 'should update cell indices after deleting the cell' do
856
+ @worksheet.delete_cell(4, 0, :left)
857
+ @worksheet[0].cells.each_with_index { |cell, i|
858
+ expect(cell.column).to eq(i)
859
+ }
860
+ end
861
+
862
+ it 'should shift cells below the deleted cell up if :up is specified' do
863
+ @worksheet.delete_cell(0,0,:up)
864
+ expect(@worksheet[0][0].value).to eq('1:0')
865
+ end
866
+
867
+ it 'should cause en error if an argument other than :left, :up, or nil is specified for shift' do
868
+ expect {
869
+ @worksheet.delete_cell(0,0,:down)
870
+ }.to raise_error(RuntimeError)
871
+ end
872
+ end
873
+
874
+ describe '.get_row_fill' do
875
+ it 'should return white (ffffff) if no fill color specified for row' do
876
+ expect(@worksheet.get_row_fill(0)).to eq('ffffff')
877
+ end
878
+
879
+ it 'should correctly reflect fill color if specified for row' do
880
+ @worksheet.change_row_fill(0, '000000')
881
+ expect(@worksheet.get_row_fill(0)).to eq('000000')
882
+ end
883
+
884
+ it 'should return nil if a row which does not exist is passed in' do
885
+ expect(@worksheet.get_row_fill(11)).to be_nil
886
+ end
887
+ end
888
+
889
+ describe '.get_row_font_name' do
890
+ it 'should correctly reflect font name for row' do
891
+ @worksheet.change_row_font_name(0, 'Courier')
892
+ expect(@worksheet.get_row_font_name(0)).to eq('Courier')
893
+ end
894
+
895
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
896
+ expect(@worksheet.get_row_font_name(11)).to be_nil
897
+ end
898
+ end
899
+
900
+ describe '.get_row_font_size' do
901
+ it 'should correctly reflect font size for row' do
902
+ @worksheet.change_row_font_size(0,30)
903
+ expect(@worksheet.get_row_font_size(0)).to eq(30)
904
+ end
905
+
906
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
907
+ expect(@worksheet.get_row_font_size(11)).to be_nil
908
+ end
909
+ end
910
+
911
+ describe '.get_row_font_color' do
912
+ it 'should correctly reflect font color for row' do
913
+ @worksheet.change_row_font_color(0, '0f0f0f')
914
+ expect(@worksheet.get_row_font_color(0)).to eq('0f0f0f')
915
+ end
916
+
917
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
918
+ expect(@worksheet.get_row_font_color(11)).to be_nil
919
+ end
920
+ end
921
+
922
+ describe '.is_row_italicized' do
923
+ it 'should correctly return whether row is italicized' do
924
+ @worksheet.change_row_italics(0, true)
925
+ expect(@worksheet.is_row_italicized(0)).to eq(true)
926
+ end
927
+
928
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
929
+ expect(@worksheet.is_row_italicized(11)).to be_nil
930
+ end
931
+ end
932
+
933
+ describe '.is_row_bolded' do
934
+ it 'should correctly return whether row is bolded' do
935
+ @worksheet.change_row_bold(0, true)
936
+ expect(@worksheet.is_row_bolded(0)).to eq(true)
937
+ end
938
+
939
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
940
+ expect(@worksheet.is_row_bolded(11)).to be_nil
941
+ end
942
+ end
943
+
944
+ describe '.is_row_underlined' do
945
+ it 'should correctly return whether row is underlined' do
946
+ @worksheet.change_row_underline(0, true)
947
+ expect(@worksheet.is_row_underlined(0)).to eq(true)
948
+ end
949
+
950
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
951
+ expect(@worksheet.is_row_underlined(11)).to be_nil
952
+ end
953
+ end
954
+
955
+ describe '.is_row_struckthrough' do
956
+ it 'should correctly return whether row is struckthrough' do
957
+ @worksheet.change_row_strikethrough(0, true)
958
+ expect(@worksheet.is_row_struckthrough(0)).to eq(true)
959
+ end
960
+
961
+ it 'should return nil if a (nonnegative) row which does not exist is passed in' do
962
+ expect(@worksheet.is_row_struckthrough(11)).to be_nil
963
+ end
964
+ end
965
+
966
+ describe '.get_row_height' do
967
+ it 'should return 13 if no height specified for row' do
968
+ expect(@worksheet.get_row_height(0)).to eq(13)
969
+ end
970
+
971
+ it 'should correctly reflect height if specified for row' do
972
+ @worksheet.change_row_height(0, 30)
973
+ expect(@worksheet.get_row_height(0)).to eq(30)
974
+ end
975
+
976
+ it 'should return default row height if a row which does not exist is passed in' do
977
+ expect(@worksheet.get_row_height(11)).to eq(13)
978
+ end
979
+
980
+ it 'should cause error if a negative argument is passed in' do
981
+ expect {
982
+ @worksheet.get_row_height(-1)
983
+ }.to raise_error(RuntimeError)
984
+ end
985
+ end
986
+
987
+ describe '.get_row_alignment' do
988
+ it 'should cause error if a negative argument is passed in' do
989
+ expect {
990
+ @worksheet.get_row_alignment(-1, true)
991
+ }.to raise_error(RuntimeError)
992
+ end
993
+
994
+ it 'should return nil if no horizontal alignment specified for row' do
995
+ expect(@worksheet.get_row_alignment(0, true)).to be_nil
996
+ end
997
+
998
+ it 'should return nil if a row which does not exist is passed in' do
999
+ expect(@worksheet.get_row_alignment(11, true)).to be_nil
1000
+ end
1001
+
1002
+ it 'should return correct horizontal alignment if it is set for that row' do
1003
+ @worksheet.change_row_horizontal_alignment(0, 'center')
1004
+ expect(@worksheet.get_row_alignment(0, true)).to eq('center')
1005
+ end
1006
+
1007
+ it 'should return nil if no alignment specified for row' do
1008
+ expect(@worksheet.get_row_alignment(0, false)).to be_nil
1009
+ end
1010
+
1011
+ it 'should return nil if a row which does not exist is passed in' do
1012
+ expect(@worksheet.get_row_alignment(11, false)).to be_nil
1013
+ end
1014
+
1015
+ it 'should return correct vertical alignment if it is set for that row' do
1016
+ @worksheet.change_row_vertical_alignment(0, 'center')
1017
+ expect(@worksheet.get_row_alignment(0, false)).to eq('center')
1018
+ end
1019
+ end
1020
+
1021
+ describe '.get_row_border' do
1022
+ it 'should return nil if no border is specified for that row in that direction' do
1023
+ expect(@worksheet.get_row_border(0, :top)).to be_nil
1024
+ end
1025
+
1026
+ it 'should return type of border that this row has on top' do
1027
+ @worksheet.change_row_border(0, :top, 'thin')
1028
+ expect(@worksheet.get_row_border(0, :top)).to eq('thin')
1029
+ end
1030
+
1031
+ it 'should cause error if a negative argument is passed in' do
1032
+ expect {
1033
+ @worksheet.get_row_border(-1, :top)
1034
+ }.to raise_error(RuntimeError)
1035
+ end
1036
+
1037
+ it 'should return nil if a row which does not exist is passed in' do
1038
+ expect(@worksheet.get_row_border(11, :top)).to be_nil
1039
+ end
1040
+ end
1041
+
1042
+ describe '.get_column_font_name' do
1043
+ it 'should correctly reflect font name for column' do
1044
+ @worksheet.change_column_font_name(0, 'Courier')
1045
+ expect(@worksheet.get_column_font_name(0)).to eq('Courier')
1046
+ end
1047
+
1048
+ it 'should cause error if a negative argument is passed in' do
1049
+ expect {
1050
+ @worksheet.get_column_font_name(-1)
1051
+ }.to raise_error(RuntimeError)
1052
+ end
1053
+
1054
+ it 'should return default font if a (nonnegative) column which does not exist is passed in' do
1055
+ expect(@worksheet.get_column_font_name(11)).to eq('Verdana')
1056
+ end
1057
+ end
1058
+
1059
+ describe '.get_column_font_size' do
1060
+ it 'should correctly reflect font size for column' do
1061
+ @worksheet.change_column_font_size(0,30)
1062
+ expect(@worksheet.get_column_font_size(0)).to eq(30)
1063
+ end
1064
+
1065
+ it 'should cause error if a negative argument is passed in' do
1066
+ expect {
1067
+ @worksheet.get_column_font_size(-1)
1068
+ }.to raise_error(RuntimeError)
1069
+ end
1070
+
1071
+ it 'should return default font size if a column which does not exist is passed in' do
1072
+ expect(@worksheet.get_column_font_size(11)).to eq(10)
1073
+ end
1074
+ end
1075
+
1076
+ describe '.get_column_font_color' do
1077
+ it 'should correctly reflect font color for column' do
1078
+ @worksheet.change_column_font_color(0, '0f0f0f')
1079
+ expect(@worksheet.get_column_font_color(0)).to eq('0f0f0f')
1080
+ end
1081
+
1082
+ it 'should cause error if a negative argument is passed in' do
1083
+ expect {
1084
+ @worksheet.get_column_font_color(-1)
1085
+ }.to raise_error(RuntimeError)
1086
+ end
1087
+
1088
+ it 'should return default color (000000) if a (nonnegative) column which does not exist is passed in' do
1089
+ expect(@worksheet.get_column_font_color(11)).to eq('000000')
1090
+ end
1091
+
1092
+ it 'should return default color (000000) if no rgb font color is specified' do
1093
+ expect(@worksheet.get_column_font_color(0)).to eq('000000')
1094
+ end
1095
+ end
1096
+
1097
+ describe '.is_column_italicized' do
1098
+ it 'should correctly return whether column is italicized' do
1099
+ @worksheet.change_column_italics(0, true)
1100
+ expect(@worksheet.is_column_italicized(0)).to eq(true)
1101
+ end
1102
+
1103
+ it 'should cause error if a negative argument is passed in' do
1104
+ expect {
1105
+ @worksheet.is_column_italicized(-1)
1106
+ }.to raise_error(RuntimeError)
1107
+ end
1108
+
1109
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1110
+ expect(@worksheet.is_column_italicized(11)).to be_nil
1111
+ end
1112
+ end
1113
+
1114
+ describe '.is_column_bolded' do
1115
+ it 'should correctly return whether column is bolded' do
1116
+ @worksheet.change_column_bold(0, true)
1117
+ expect(@worksheet.is_column_bolded(0)).to eq(true)
1118
+ end
1119
+
1120
+ it 'should cause error if a negative argument is passed in' do
1121
+ expect {
1122
+ @worksheet.is_column_bolded(-1)
1123
+ }.to raise_error(RuntimeError)
1124
+ end
1125
+
1126
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1127
+ expect(@worksheet.is_column_bolded(11)).to be_nil
1128
+ end
1129
+ end
1130
+
1131
+ describe '.is_column_underlined' do
1132
+ it 'should correctly return whether column is underlined' do
1133
+ @worksheet.change_column_underline(0, true)
1134
+ expect(@worksheet.is_column_underlined(0)).to eq(true)
1135
+ end
1136
+
1137
+ it 'should cause error if a negative argument is passed in' do
1138
+ expect {
1139
+ @worksheet.is_column_underlined(-1)
1140
+ }.to raise_error(RuntimeError)
1141
+ end
1142
+
1143
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1144
+ expect(@worksheet.is_column_underlined(11)).to be_nil
1145
+ end
1146
+ end
1147
+
1148
+ describe '.is_column_struckthrough' do
1149
+ it 'should correctly return whether column is struckthrough' do
1150
+ @worksheet.change_column_strikethrough(0, true)
1151
+ expect(@worksheet.is_column_struckthrough(0)).to eq(true)
1152
+ end
1153
+
1154
+ it 'should cause error if a negative argument is passed in' do
1155
+ expect {
1156
+ @worksheet.is_column_struckthrough(-1)
1157
+ }.to raise_error(RuntimeError)
1158
+ end
1159
+
1160
+ it 'should return nil if a (nonnegative) column which does not exist is passed in' do
1161
+ expect(@worksheet.is_column_struckthrough(11)).to be_nil
1162
+ end
1163
+ end
1164
+
1165
+ describe '.get_column_width_raw' do
1166
+ it 'should return nil if no width specified for column' do
1167
+ expect(@worksheet.get_column_width_raw(0)).to be_nil
1168
+ end
1169
+
1170
+ it 'should correctly reflect width if specified for column' do
1171
+ @worksheet.change_column_width_raw(0, 30.123)
1172
+ expect(@worksheet.get_column_width_raw(0)).to eq(30.123)
1173
+ end
1174
+
1175
+ it 'should return nil for a column that does not exist' do
1176
+ expect(@worksheet.get_column_width_raw(11)).to be_nil
1177
+ end
1178
+
1179
+ it 'should cause error if a negative argument is passed in' do
1180
+ expect {
1181
+ @worksheet.get_column_width_raw(-1)
1182
+ }.to raise_error(RuntimeError)
1183
+ end
1184
+ end
1185
+
1186
+ describe '.get_column_width' do
1187
+ it 'should return default width if no width specified for column' do
1188
+ expect(@worksheet.get_column_width(0)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
1189
+ end
1190
+
1191
+ it 'should correctly reflect width if specified for column' do
1192
+ @worksheet.change_column_width(0, 15)
1193
+ expect(@worksheet.get_column_width(0)).to eq(15)
1194
+ end
1195
+
1196
+ it 'should return default width for a column that does not exist' do
1197
+ expect(@worksheet.get_column_width(11)).to eq(RubyXL::ColumnRange::DEFAULT_WIDTH)
1198
+ end
1199
+
1200
+ it 'should cause error if a negative argument is passed in' do
1201
+ expect {
1202
+ @worksheet.get_column_width(-1)
1203
+ }.to raise_error(RuntimeError)
1204
+ end
1205
+ end
1206
+
1207
+ describe '.get_column_fill' do
1208
+ it 'should return white (ffffff) if no fill color specified for column' do
1209
+ expect(@worksheet.get_column_fill(0)).to eq('ffffff')
1210
+ end
1211
+
1212
+ it 'should correctly reflect fill color if specified for column' do
1213
+ @worksheet.change_column_fill(0, '000000')
1214
+ expect(@worksheet.get_column_fill(0)).to eq('000000')
1215
+ end
1216
+
1217
+ it 'should return nil if a column which does not exist is passed in' do
1218
+ expect(@worksheet.get_column_fill(11)).to eq('ffffff')
1219
+ end
1220
+
1221
+ it 'should cause error if a negative argument is passed in' do
1222
+ expect {
1223
+ @worksheet.get_column_fill(-1)
1224
+ }.to raise_error(RuntimeError)
1225
+ end
1226
+ end
1227
+
1228
+ describe '.get_column_horizontal_alignment' do
1229
+ it 'should return nil if no alignment specified for column' do
1230
+ expect(@worksheet.get_column_alignment(0, :horizontal)).to be_nil
1231
+ end
1232
+
1233
+ it 'should return nil if a column which does not exist is passed in' do
1234
+ expect(@worksheet.get_column_alignment(11, :horizontal)).to be_nil
1235
+ end
1236
+
1237
+ it 'should cause error if a negative argument is passed in' do
1238
+ expect {
1239
+ @worksheet.get_column_alignment(-1, :horizontal)
1240
+ }.to raise_error(RuntimeError)
1241
+ end
1242
+
1243
+ it 'should return correct horizontal alignment if it is set for that column' do
1244
+ @worksheet.change_column_horizontal_alignment(0, 'center')
1245
+ expect(@worksheet.get_column_alignment(0, :horizontal)).to eq('center')
1246
+ end
1247
+ end
1248
+
1249
+ describe '.get_column_vertical_alignment' do
1250
+ it 'should return nil if no alignment specified for column' do
1251
+ expect(@worksheet.get_column_alignment(0, :vertical)).to be_nil
1252
+ end
1253
+
1254
+ it 'should return nil if a column which does not exist is passed in' do
1255
+ expect(@worksheet.get_column_alignment(11, :vertical)).to be_nil
1256
+ end
1257
+
1258
+ it 'should cause error if a negative argument is passed in' do
1259
+ expect {
1260
+ @worksheet.get_column_alignment(-1, :vertical)
1261
+ }.to raise_error(RuntimeError)
1262
+ end
1263
+
1264
+ it 'should return correct vertical alignment if it is set for that column' do
1265
+ @worksheet.change_column_vertical_alignment(0, 'center')
1266
+ expect(@worksheet.get_column_alignment(0, :vertical)).to eq('center')
1267
+ end
1268
+ end
1269
+
1270
+ describe '.get_column_border' do
1271
+ it 'should return nil if no border is specified for that column in that direction' do
1272
+ expect(@worksheet.get_column_border(0, :diagonal)).to be_nil
1273
+ end
1274
+
1275
+ it 'should return type of border that this column has on diagonal' do
1276
+ @worksheet.change_column_border(0, :diagonal, 'thin')
1277
+ expect(@worksheet.get_column_border(0, :diagonal)).to eq('thin')
1278
+ end
1279
+
1280
+ it 'should cause error if a negative argument is passed in' do
1281
+ expect {
1282
+ @worksheet.get_column_border(-1, :diagonal)
1283
+ }.to raise_error(RuntimeError)
1284
+ end
1285
+
1286
+ it 'should return nil if a column which does not exist is passed in' do
1287
+ expect(@worksheet.get_column_border(11, :diagonal)).to be_nil
1288
+ end
1289
+ end
1290
+
1291
+ describe '@column_range' do
1292
+ it 'should properly handle range addition and modification' do
1293
+ # Ranges should be empty for brand new worskeet
1294
+ expect(@worksheet.cols.size).to eq(0)
1295
+
1296
+ # Range should be created if the column has not been touched before
1297
+ @worksheet.change_column_width(0, 30)
1298
+ expect(@worksheet.get_column_width(0)).to eq(30)
1299
+ expect(@worksheet.cols.size).to eq(1)
1300
+
1301
+ # Existing range should be reused
1302
+ @worksheet.change_column_width(0, 20)
1303
+ expect(@worksheet.get_column_width(0)).to eq(20)
1304
+ expect(@worksheet.cols.size).to eq(1)
1305
+
1306
+ # Creation of the new range should not affect previously changed columns
1307
+ @worksheet.change_column_width(1, 30)
1308
+ expect(@worksheet.get_column_width(1)).to eq(30)
1309
+ expect(@worksheet.get_column_width(0)).to eq(20)
1310
+ expect(@worksheet.cols.size).to eq(2)
1311
+
1312
+ @worksheet.cols.clear
1313
+ @worksheet.cols << RubyXL::ColumnRange.new(:min => 1, :max => 9, :width => 33) # Note that this is raw width
1314
+
1315
+ r = @worksheet.cols.locate_range(3)
1316
+ expect(r.min).to eq(1)
1317
+ expect(r.max).to eq(9)
1318
+
1319
+ # When a column is modified at the beginning of the range, it should shrink to the right
1320
+ @worksheet.change_column_width(0, 20)
1321
+ expect(@worksheet.cols.size).to eq(2)
1322
+ expect(@worksheet.get_column_width(0)).to eq(20)
1323
+ expect(@worksheet.get_column_width(1)).to eq(32)
1324
+
1325
+ r = @worksheet.cols.locate_range(3)
1326
+ expect(r.min).to eq(2)
1327
+ expect(r.max).to eq(9)
1328
+
1329
+ # When a column is modified at the beginning of the range, it should shrink to the left
1330
+ @worksheet.change_column_width(8, 30)
1331
+ expect(@worksheet.cols.size).to eq(3)
1332
+ expect(@worksheet.get_column_width(8)).to eq(30)
1333
+
1334
+ r = @worksheet.cols.locate_range(3)
1335
+ expect(r.min).to eq(2)
1336
+ expect(r.max).to eq(8)
1337
+
1338
+ # When a column is modified in the middle of the range, it should split into two
1339
+ @worksheet.change_column_width(4, 15)
1340
+ expect(@worksheet.cols.size).to eq(5)
1341
+ expect(@worksheet.get_column_width(3)).to eq(32)
1342
+
1343
+ r = @worksheet.cols.locate_range(2)
1344
+ expect(r.min).to eq(2)
1345
+ expect(r.max).to eq(4)
1346
+
1347
+ expect(@worksheet.get_column_width(4)).to eq(15)
1348
+
1349
+ r = @worksheet.cols.locate_range(4)
1350
+ expect(r.min).to eq(5)
1351
+ expect(r.max).to eq(5)
1352
+
1353
+ expect(@worksheet.get_column_width(5)).to eq(32)
1354
+
1355
+ r = @worksheet.cols.locate_range(6)
1356
+ expect(r.min).to eq(6)
1357
+ expect(r.max).to eq(8)
1358
+
1359
+ end
1360
+
1361
+ end
1362
+
1363
+ end