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