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