rubyXL 3.3.21 → 3.4.17
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 +3 -2
- data/Gemfile.lock +96 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +47 -16
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/lib/rubyXL.rb +1 -0
- data/lib/rubyXL/cell.rb +1 -26
- data/lib/rubyXL/convenience_methods.rb +5 -982
- data/lib/rubyXL/convenience_methods/cell.rb +272 -0
- data/lib/rubyXL/convenience_methods/color.rb +160 -0
- data/lib/rubyXL/convenience_methods/font.rb +63 -0
- data/lib/rubyXL/convenience_methods/workbook.rb +136 -0
- data/lib/rubyXL/convenience_methods/worksheet.rb +710 -0
- data/lib/rubyXL/objects/border.rb +31 -3
- data/lib/rubyXL/objects/calculation_chain.rb +2 -2
- data/lib/rubyXL/objects/cell_style.rb +8 -8
- data/lib/rubyXL/objects/chartsheet.rb +10 -10
- data/lib/rubyXL/objects/color.rb +6 -4
- data/lib/rubyXL/objects/column_range.rb +10 -10
- data/lib/rubyXL/objects/comments.rb +6 -6
- data/lib/rubyXL/objects/connection.rb +175 -0
- data/lib/rubyXL/objects/container_nodes.rb +2 -2
- data/lib/rubyXL/objects/content_types.rb +2 -2
- data/lib/rubyXL/objects/data_validation.rb +4 -2
- data/lib/rubyXL/objects/document_properties.rb +3 -3
- data/lib/rubyXL/objects/extensions.rb +20 -3
- data/lib/rubyXL/objects/external_links.rb +26 -2
- data/lib/rubyXL/objects/fill.rb +4 -4
- data/lib/rubyXL/objects/filters.rb +12 -12
- data/lib/rubyXL/objects/font.rb +2 -60
- data/lib/rubyXL/objects/formula.rb +1 -1
- data/lib/rubyXL/objects/ooxml_object.rb +15 -3
- data/lib/rubyXL/objects/query_table.rb +104 -0
- data/lib/rubyXL/objects/relationships.rb +8 -3
- data/lib/rubyXL/objects/shared_strings.rb +1 -1
- data/lib/rubyXL/objects/sheet_common.rb +4 -4
- data/lib/rubyXL/objects/sheet_data.rb +48 -11
- data/lib/rubyXL/objects/simple_types.rb +18 -0
- data/lib/rubyXL/objects/storage.rb +25 -1
- data/lib/rubyXL/objects/stylesheet.rb +14 -14
- data/lib/rubyXL/objects/text.rb +8 -8
- data/lib/rubyXL/objects/theme.rb +138 -119
- data/lib/rubyXL/objects/workbook.rb +153 -43
- data/lib/rubyXL/objects/worksheet.rb +118 -107
- data/lib/rubyXL/worksheet.rb +19 -13
- data/rdoc/README_rdoc.html +109 -103
- data/rdoc/RubyXL.html +39 -296
- 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 +76 -53
- data/rdoc/RubyXL/BorderEdge.html +71 -17
- 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 +144 -204
- data/rdoc/RubyXL/CellConvenienceMethods.html +240 -426
- 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 +18 -38
- data/rdoc/RubyXL/CellStyles.html +18 -38
- 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 +19 -39
- 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 +19 -67
- 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 +28 -39
- data/rdoc/RubyXL/ColorConvenienceClasses.html +91 -0
- data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +242 -0
- data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +279 -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 +20 -71
- data/rdoc/RubyXL/ColumnRanges.html +20 -79
- data/rdoc/RubyXL/Comment.html +13 -19
- data/rdoc/RubyXL/CommentList.html +13 -19
- data/rdoc/RubyXL/CommentsFile.html +17 -50
- 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 +23 -63
- data/rdoc/RubyXL/ControlPropertiesFile.html +14 -22
- data/rdoc/RubyXL/CorePropertiesFile.html +26 -162
- 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 +20 -66
- 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 +18 -38
- data/rdoc/RubyXL/Fills.html +18 -38
- 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 +19 -81
- 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 +18 -38
- data/rdoc/RubyXL/NumberFormats.html +18 -44
- 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 +88 -179
- data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +47 -183
- data/rdoc/RubyXL/OOXMLRelationshipsFile.html +42 -194
- 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 +20 -53
- 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 +19 -58
- data/rdoc/RubyXL/Reference.html +31 -215
- data/rdoc/RubyXL/Relationship.html +12 -17
- data/rdoc/RubyXL/RelationshipSupport.html +32 -126
- data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +15 -33
- data/rdoc/RubyXL/RevisionPointer.html +99 -0
- data/rdoc/RubyXL/RichText.html +18 -38
- data/rdoc/RubyXL/RichTextRun.html +17 -37
- 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 +20 -40
- data/rdoc/RubyXL/ShapeGuide.html +13 -19
- data/rdoc/RubyXL/ShapeTextRectangle.html +13 -19
- data/rdoc/RubyXL/SharedStringsTable.html +31 -140
- 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/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 +18 -51
- data/rdoc/RubyXL/Stop.html +13 -19
- data/rdoc/RubyXL/StringNode.html +12 -17
- data/rdoc/RubyXL/StringNodeW3C.html +19 -52
- data/rdoc/RubyXL/StringValue.html +12 -17
- data/rdoc/RubyXL/Stylesheet.html +30 -112
- 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 +19 -63
- data/rdoc/RubyXL/TextImportSettings.html +99 -0
- data/rdoc/RubyXL/Theme.html +58 -63
- 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 +17 -37
- 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 +483 -226
- data/rdoc/RubyXL/WorkbookConvenienceMethods.html +149 -857
- data/rdoc/RubyXL/WorkbookProperties.html +13 -19
- data/rdoc/RubyXL/WorkbookProtection.html +13 -19
- data/rdoc/RubyXL/WorkbookRoot.html +23 -109
- data/rdoc/RubyXL/WorkbookView.html +13 -19
- data/rdoc/RubyXL/WorkbookViews.html +13 -19
- data/rdoc/RubyXL/Worksheet.html +70 -122
- data/rdoc/RubyXL/WorksheetConvenienceMethods.html +398 -1049
- 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/created.rid +45 -38
- data/rdoc/css/fonts.css +6 -6
- data/rdoc/css/rdoc.css +35 -6
- data/rdoc/index.html +43 -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 +368 -75
- data/rubyXL.gemspec +60 -26
- data/spec/lib/cell_spec.rb +147 -2
- data/spec/lib/color_spec.rb +1 -0
- data/spec/lib/parser_spec.rb +1 -1
- data/spec/lib/rgb_color_spec.rb +16 -0
- data/spec/lib/text_spec.rb +8 -0
- data/spec/lib/workbook_spec.rb +12 -1
- data/spec/lib/worksheet_spec.rb +353 -37
- data/test/test_parse_write.rb +15 -15
- metadata +63 -9
- data/rdoc/js/jquery.js +0 -4
@@ -0,0 +1,136 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
module WorkbookConvenienceMethods
|
4
|
+
|
5
|
+
def each
|
6
|
+
worksheets.each{ |i| yield i }
|
7
|
+
end
|
8
|
+
|
9
|
+
def cell_xfs # Stylesheet should be pre-filled with defaults on initialize()
|
10
|
+
stylesheet.cell_xfs
|
11
|
+
end
|
12
|
+
|
13
|
+
def fonts # Stylesheet should be pre-filled with defaults on initialize()
|
14
|
+
stylesheet.fonts
|
15
|
+
end
|
16
|
+
|
17
|
+
def fills # Stylesheet should be pre-filled with defaults on initialize()
|
18
|
+
stylesheet.fills
|
19
|
+
end
|
20
|
+
|
21
|
+
def borders # Stylesheet should be pre-filled with defaults on initialize()
|
22
|
+
stylesheet.borders
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_fill_color(xf)
|
26
|
+
fill = fills[xf.fill_id]
|
27
|
+
pattern = fill && fill.pattern_fill
|
28
|
+
color = pattern && pattern.fg_color
|
29
|
+
color = color && color.get_rgb(self)
|
30
|
+
color && color.to_s || 'ffffff'
|
31
|
+
end
|
32
|
+
|
33
|
+
def register_new_fill(new_fill, old_xf)
|
34
|
+
new_xf = old_xf.dup
|
35
|
+
new_xf.apply_fill = true
|
36
|
+
new_xf.fill_id = fills.find_index { |x| x == new_fill } # Reuse existing fill, if it exists
|
37
|
+
new_xf.fill_id ||= fills.size # If this fill has never existed before, add it to collection.
|
38
|
+
fills[new_xf.fill_id] = new_fill
|
39
|
+
new_xf
|
40
|
+
end
|
41
|
+
|
42
|
+
def register_new_font(new_font, old_xf)
|
43
|
+
new_xf = old_xf.dup
|
44
|
+
new_xf.font_id = fonts.find_index { |x| x == new_font } # Reuse existing font, if it exists
|
45
|
+
new_xf.font_id ||= fonts.size # If this font has never existed before, add it to collection.
|
46
|
+
fonts[new_xf.font_id] = new_font
|
47
|
+
new_xf.apply_font = true
|
48
|
+
new_xf
|
49
|
+
end
|
50
|
+
|
51
|
+
def register_new_xf(new_xf)
|
52
|
+
new_xf_id = cell_xfs.find_index { |xf| xf == new_xf } # Reuse existing XF, if it exists
|
53
|
+
new_xf_id ||= cell_xfs.size # If this XF has never existed before, add it to collection.
|
54
|
+
cell_xfs[new_xf_id] = new_xf
|
55
|
+
new_xf_id
|
56
|
+
end
|
57
|
+
|
58
|
+
def modify_alignment(style_index, &block)
|
59
|
+
old_xf = cell_xfs[style_index || 0]
|
60
|
+
new_xf = old_xf.dup
|
61
|
+
if old_xf.alignment then
|
62
|
+
new_xf.alignment = old_xf.alignment.dup
|
63
|
+
else
|
64
|
+
new_xf.alignment = RubyXL::Alignment.new
|
65
|
+
end
|
66
|
+
|
67
|
+
yield(new_xf.alignment)
|
68
|
+
new_xf.apply_alignment = true
|
69
|
+
|
70
|
+
register_new_xf(new_xf)
|
71
|
+
end
|
72
|
+
|
73
|
+
def modify_fill(style_index, rgb)
|
74
|
+
xf = cell_xfs[style_index || 0].dup
|
75
|
+
new_fill = RubyXL::Fill.new(:pattern_fill =>
|
76
|
+
RubyXL::PatternFill.new(:pattern_type => 'solid',
|
77
|
+
:fg_color => RubyXL::Color.new(:rgb => rgb)))
|
78
|
+
register_new_xf(register_new_fill(new_fill, xf))
|
79
|
+
end
|
80
|
+
|
81
|
+
def modify_border(style_index, direction, weight)
|
82
|
+
xf = cell_xfs[style_index || 0].dup
|
83
|
+
new_border = borders[xf.border_id || 0].dup
|
84
|
+
|
85
|
+
edge = new_border.send(direction)
|
86
|
+
new_border.send("#{direction}=", edge.dup) if edge
|
87
|
+
|
88
|
+
new_border.set_edge_style(direction, weight)
|
89
|
+
|
90
|
+
xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
|
91
|
+
xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
|
92
|
+
borders[xf.border_id] = new_border
|
93
|
+
xf.apply_border = true
|
94
|
+
|
95
|
+
register_new_xf(xf)
|
96
|
+
end
|
97
|
+
|
98
|
+
def modify_border_color(style_index, direction, color)
|
99
|
+
xf = cell_xfs[style_index || 0].dup
|
100
|
+
new_border = borders[xf.border_id || 0].dup
|
101
|
+
new_border.set_edge_color(direction, color)
|
102
|
+
|
103
|
+
xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
|
104
|
+
xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
|
105
|
+
borders[xf.border_id] = new_border
|
106
|
+
xf.apply_border = true
|
107
|
+
|
108
|
+
register_new_xf(xf)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Calculate password hash from string for use in 'password' fields.
|
112
|
+
# https://www.openoffice.org/sc/excelfileformat.pdf
|
113
|
+
def password_hash(pwd)
|
114
|
+
hsh = 0
|
115
|
+
pwd.reverse.each_char { |c|
|
116
|
+
hsh = hsh ^ c.ord
|
117
|
+
hsh = hsh << 1
|
118
|
+
hsh -= 0x7fff if hsh > 0x7fff
|
119
|
+
}
|
120
|
+
|
121
|
+
(hsh ^ pwd.length ^ 0xCE4B).to_s(16)
|
122
|
+
end
|
123
|
+
|
124
|
+
def define_new_name(name, reference)
|
125
|
+
self.defined_names ||= RubyXL::DefinedNames.new
|
126
|
+
self.defined_names << RubyXL::DefinedName.new({:name => name, :reference => reference})
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_defined_name(name)
|
130
|
+
self.defined_names && self.defined_names.find { |n| n.name == name }
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
RubyXL::Workbook.send(:include, RubyXL::WorkbookConvenienceMethods) # ruby 2.1 compat
|
136
|
+
end
|
@@ -0,0 +1,710 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
module WorksheetConvenienceMethods
|
4
|
+
NAME = 0
|
5
|
+
SIZE = 1
|
6
|
+
COLOR = 2
|
7
|
+
ITALICS = 3
|
8
|
+
BOLD = 4
|
9
|
+
UNDERLINE = 5
|
10
|
+
STRIKETHROUGH = 6
|
11
|
+
|
12
|
+
def insert_cell(row = 0, col = 0, data = nil, formula = nil, shift = nil)
|
13
|
+
validate_workbook
|
14
|
+
ensure_cell_exists(row, col)
|
15
|
+
|
16
|
+
case shift
|
17
|
+
when nil then # No shifting at all
|
18
|
+
when :right then
|
19
|
+
sheet_data.rows[row].insert_cell_shift_right(nil, col)
|
20
|
+
when :down then
|
21
|
+
add_row(sheet_data.size, :cells => Array.new(sheet_data.rows[row].size))
|
22
|
+
(sheet_data.size - 1).downto(row + 1) { |index|
|
23
|
+
old_row = sheet_data.rows[index - 1]
|
24
|
+
if old_row.nil? then
|
25
|
+
sheet_data.rows[index] = nil
|
26
|
+
else
|
27
|
+
new_row = sheet_data.rows[index] || add_row(index)
|
28
|
+
new_row.cells[col] = old_row.cells[col]
|
29
|
+
end
|
30
|
+
}
|
31
|
+
else
|
32
|
+
raise 'invalid shift option'
|
33
|
+
end
|
34
|
+
|
35
|
+
return add_cell(row, col, data, formula)
|
36
|
+
end
|
37
|
+
|
38
|
+
# by default, only sets cell to nil
|
39
|
+
# if :left is specified, method will shift row contents to the right of the deleted cell to the left
|
40
|
+
# if :up is specified, method will shift column contents below the deleted cell upward
|
41
|
+
def delete_cell(row_index = 0, column_index=0, shift=nil)
|
42
|
+
validate_workbook
|
43
|
+
validate_nonnegative(row_index)
|
44
|
+
validate_nonnegative(column_index)
|
45
|
+
|
46
|
+
row = sheet_data[row_index]
|
47
|
+
old_cell = row && row[column_index]
|
48
|
+
|
49
|
+
case shift
|
50
|
+
when nil then
|
51
|
+
row.cells[column_index] = nil if row
|
52
|
+
when :left then
|
53
|
+
row.delete_cell_shift_left(column_index) if row
|
54
|
+
when :up then
|
55
|
+
(row_index...(sheet_data.size - 1)).each { |index|
|
56
|
+
old_row = sheet_data.rows[index + 1]
|
57
|
+
if old_row.nil? then
|
58
|
+
sheet_data.rows[index] = nil
|
59
|
+
else
|
60
|
+
new_row = sheet_data.rows[index] || add_row(index)
|
61
|
+
c = new_row.cells[column_index] = old_row.cells[column_index]
|
62
|
+
c.row = (index + 1) if c.is_a?(Cell)
|
63
|
+
end
|
64
|
+
}
|
65
|
+
else
|
66
|
+
raise 'invalid shift option'
|
67
|
+
end
|
68
|
+
|
69
|
+
return old_cell
|
70
|
+
end
|
71
|
+
|
72
|
+
# Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!)
|
73
|
+
# NOTE: use of this method will break formulas which reference cells which are being "pushed down"
|
74
|
+
def insert_row(row_index = 0)
|
75
|
+
validate_workbook
|
76
|
+
ensure_cell_exists(row_index)
|
77
|
+
|
78
|
+
old_row = new_cells = nil
|
79
|
+
|
80
|
+
if row_index > 0 then
|
81
|
+
old_row = sheet_data.rows[row_index - 1]
|
82
|
+
if old_row then
|
83
|
+
new_cells = old_row.cells.collect { |c|
|
84
|
+
if c.nil? then nil
|
85
|
+
else nc = RubyXL::Cell.new(:style_index => c.style_index)
|
86
|
+
nc.worksheet = self
|
87
|
+
nc
|
88
|
+
end
|
89
|
+
}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
row0 = sheet_data.rows[0]
|
94
|
+
new_cells ||= Array.new((row0 && row0.cells.size) || 0)
|
95
|
+
|
96
|
+
sheet_data.rows.insert(row_index, nil)
|
97
|
+
new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
|
98
|
+
|
99
|
+
# Update row values for all rows below
|
100
|
+
row_index.upto(sheet_data.rows.size - 1) { |r|
|
101
|
+
row = sheet_data.rows[r]
|
102
|
+
next if row.nil?
|
103
|
+
row.cells.each_with_index { |cell, c|
|
104
|
+
next if cell.nil?
|
105
|
+
cell.r = RubyXL::Reference.new(r, c)
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
# Update merged cells for all rows below
|
110
|
+
self.merged_cells ||= RubyXL::MergedCells.new
|
111
|
+
merged_cells.each { |mc|
|
112
|
+
next if mc.ref.row_range.last < row_index
|
113
|
+
|
114
|
+
in_merged_cell = mc.ref.row_range.first < row_index
|
115
|
+
mc.ref = RubyXL::Reference.new(
|
116
|
+
mc.ref.row_range.first + (in_merged_cell ? 0 : 1),
|
117
|
+
mc.ref.row_range.last + 1,
|
118
|
+
mc.ref.col_range.first,
|
119
|
+
mc.ref.col_range.last,
|
120
|
+
)
|
121
|
+
}
|
122
|
+
|
123
|
+
return new_row
|
124
|
+
end
|
125
|
+
|
126
|
+
def delete_row(row_index=0)
|
127
|
+
validate_workbook
|
128
|
+
validate_nonnegative(row_index)
|
129
|
+
|
130
|
+
deleted = sheet_data.rows.delete_at(row_index)
|
131
|
+
|
132
|
+
# Update row number of each cell
|
133
|
+
row_index.upto(sheet_data.size - 1) { |index|
|
134
|
+
row = sheet_data[index]
|
135
|
+
row && row.cells.each{ |c| c.row -= 1 unless c.nil? }
|
136
|
+
}
|
137
|
+
|
138
|
+
# Update row number of merged cells
|
139
|
+
self.merged_cells ||= RubyXL::MergedCells.new
|
140
|
+
merged_cells.delete_if { |mc| mc.ref.row_range == (row_index..row_index) }
|
141
|
+
merged_cells.each { |mc|
|
142
|
+
next if mc.ref.row_range.last < row_index
|
143
|
+
|
144
|
+
in_merged_cell = mc.ref.row_range.first <= row_index
|
145
|
+
mc.ref = RubyXL::Reference.new(
|
146
|
+
mc.ref.row_range.first - (in_merged_cell ? 0 : 1),
|
147
|
+
mc.ref.row_range.last - 1,
|
148
|
+
mc.ref.col_range.first,
|
149
|
+
mc.ref.col_range.last,
|
150
|
+
)
|
151
|
+
}
|
152
|
+
merged_cells.delete_if { |mc| mc.ref.single_cell? }
|
153
|
+
|
154
|
+
return deleted
|
155
|
+
end
|
156
|
+
|
157
|
+
# Inserts column at +column_index+, pushes everything right, takes styles from column to left
|
158
|
+
# NOTE: use of this method will break formulas which reference cells which are being "pushed right"
|
159
|
+
def insert_column(column_index = 0)
|
160
|
+
validate_workbook
|
161
|
+
ensure_cell_exists(0, column_index)
|
162
|
+
|
163
|
+
old_range = cols.get_range(column_index)
|
164
|
+
|
165
|
+
# Go through each cell in column
|
166
|
+
sheet_data.rows.each_with_index { |row, row_index|
|
167
|
+
next if row.nil? # Do not process blank rows
|
168
|
+
|
169
|
+
old_cell = row[column_index]
|
170
|
+
c = nil
|
171
|
+
|
172
|
+
if old_cell && old_cell.style_index != 0 &&
|
173
|
+
old_range && old_range.style_index != old_cell.style_index then
|
174
|
+
|
175
|
+
c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
|
176
|
+
:row => row_index, :column => column_index,
|
177
|
+
:datatype => RubyXL::DataType::SHARED_STRING)
|
178
|
+
end
|
179
|
+
|
180
|
+
row.insert_cell_shift_right(c, column_index)
|
181
|
+
}
|
182
|
+
|
183
|
+
cols.insert_column(column_index)
|
184
|
+
|
185
|
+
# Update merged cells for all rows below
|
186
|
+
self.merged_cells ||= RubyXL::MergedCells.new
|
187
|
+
merged_cells.each { |mc|
|
188
|
+
next if mc.ref.col_range.last < column_index
|
189
|
+
|
190
|
+
in_merged_cell = mc.ref.row_range.first < column_index
|
191
|
+
mc.ref = RubyXL::Reference.new(
|
192
|
+
mc.ref.row_range.first,
|
193
|
+
mc.ref.row_range.last,
|
194
|
+
mc.ref.col_range.first + (in_merged_cell ? 0 : 1),
|
195
|
+
mc.ref.col_range.last + 1,
|
196
|
+
)
|
197
|
+
}
|
198
|
+
|
199
|
+
# TODO: update column numbers
|
200
|
+
end
|
201
|
+
|
202
|
+
def delete_column(column_index = 0)
|
203
|
+
validate_workbook
|
204
|
+
validate_nonnegative(column_index)
|
205
|
+
|
206
|
+
# Delete column
|
207
|
+
sheet_data.rows.each { |row| row && row.cells.delete_at(column_index) }
|
208
|
+
|
209
|
+
# Update column numbers for cells to the right of the deleted column
|
210
|
+
sheet_data.rows.each_with_index { |row, row_index|
|
211
|
+
next if row.nil?
|
212
|
+
row.cells.each_with_index { |c, ci|
|
213
|
+
c.column = ci if c.is_a?(Cell)
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
cols.each { |range| range.delete_column(column_index) }
|
218
|
+
|
219
|
+
# Update row number of merged cells
|
220
|
+
self.merged_cells ||= RubyXL::MergedCells.new
|
221
|
+
merged_cells.delete_if { |mc| mc.ref.col_range == (column_index..column_index) }
|
222
|
+
merged_cells.each { |mc|
|
223
|
+
next if mc.ref.col_range.last < column_index
|
224
|
+
|
225
|
+
in_merged_cell = mc.ref.col_range.first <= column_index
|
226
|
+
mc.ref = RubyXL::Reference.new(
|
227
|
+
mc.ref.row_range.first,
|
228
|
+
mc.ref.row_range.last,
|
229
|
+
mc.ref.col_range.first - (in_merged_cell ? 0 : 1),
|
230
|
+
mc.ref.col_range.last - 1,
|
231
|
+
)
|
232
|
+
}
|
233
|
+
merged_cells.delete_if { |mc| mc.ref.single_cell? }
|
234
|
+
end
|
235
|
+
|
236
|
+
def get_row_style(row_index)
|
237
|
+
row = sheet_data.rows[row_index]
|
238
|
+
(row && row.style_index) || 0
|
239
|
+
end
|
240
|
+
|
241
|
+
def get_row_fill(row = 0)
|
242
|
+
(row = sheet_data.rows[row]) && row.get_fill_color
|
243
|
+
end
|
244
|
+
|
245
|
+
def get_row_font_name(row = 0)
|
246
|
+
(font = row_font(row)) && font.get_name
|
247
|
+
end
|
248
|
+
|
249
|
+
def get_row_font_size(row = 0)
|
250
|
+
(font = row_font(row)) && font.get_size
|
251
|
+
end
|
252
|
+
|
253
|
+
def get_row_font_color(row = 0)
|
254
|
+
font = row_font(row)
|
255
|
+
color = font && font.color
|
256
|
+
color && (color.rgb || '000000')
|
257
|
+
end
|
258
|
+
|
259
|
+
def is_row_italicized(row = 0)
|
260
|
+
(font = row_font(row)) && font.is_italic
|
261
|
+
end
|
262
|
+
|
263
|
+
def is_row_bolded(row = 0)
|
264
|
+
(font = row_font(row)) && font.is_bold
|
265
|
+
end
|
266
|
+
|
267
|
+
def is_row_underlined(row = 0)
|
268
|
+
(font = row_font(row)) && font.is_underlined
|
269
|
+
end
|
270
|
+
|
271
|
+
def is_row_struckthrough(row = 0)
|
272
|
+
(font = row_font(row)) && font.is_strikethrough
|
273
|
+
end
|
274
|
+
|
275
|
+
def get_row_height(row = 0)
|
276
|
+
validate_workbook
|
277
|
+
validate_nonnegative(row)
|
278
|
+
row = sheet_data.rows[row]
|
279
|
+
row && row.ht || RubyXL::Row::DEFAULT_HEIGHT
|
280
|
+
end
|
281
|
+
|
282
|
+
def get_row_border(row, border_direction)
|
283
|
+
validate_workbook
|
284
|
+
|
285
|
+
border = @workbook.borders[get_row_xf(row).border_id]
|
286
|
+
border && border.get_edge_style(border_direction)
|
287
|
+
end
|
288
|
+
|
289
|
+
def get_row_border_color(row, border_direction)
|
290
|
+
validate_workbook
|
291
|
+
|
292
|
+
border = @workbook.borders[get_row_xf(row).border_id]
|
293
|
+
border && border.get_edge_color(border_direction)
|
294
|
+
end
|
295
|
+
|
296
|
+
def row_font(row)
|
297
|
+
(row = sheet_data.rows[row]) && row.get_font
|
298
|
+
end
|
299
|
+
|
300
|
+
def get_row_alignment(row, is_horizontal)
|
301
|
+
validate_workbook
|
302
|
+
|
303
|
+
xf_obj = get_row_xf(row)
|
304
|
+
return nil if xf_obj.alignment.nil?
|
305
|
+
|
306
|
+
if is_horizontal then return xf_obj.alignment.horizontal
|
307
|
+
else return xf_obj.alignment.vertical
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def get_cols_style_index(column_index)
|
312
|
+
validate_nonnegative(column_index)
|
313
|
+
range = cols.locate_range(column_index)
|
314
|
+
(range && range.style_index) || 0
|
315
|
+
end
|
316
|
+
|
317
|
+
def get_column_font_name(col = 0)
|
318
|
+
font = column_font(col)
|
319
|
+
font && font.get_name
|
320
|
+
end
|
321
|
+
|
322
|
+
def get_column_font_size(col = 0)
|
323
|
+
font = column_font(col)
|
324
|
+
font && font.get_size
|
325
|
+
end
|
326
|
+
|
327
|
+
def get_column_font_color(col = 0)
|
328
|
+
font = column_font(col)
|
329
|
+
font && (font.get_rgb_color || '000000')
|
330
|
+
end
|
331
|
+
|
332
|
+
def is_column_italicized(col = 0)
|
333
|
+
font = column_font(col)
|
334
|
+
font && font.is_italic
|
335
|
+
end
|
336
|
+
|
337
|
+
def is_column_bolded(col = 0)
|
338
|
+
font = column_font(col)
|
339
|
+
font && font.is_bold
|
340
|
+
end
|
341
|
+
|
342
|
+
def is_column_underlined(col = 0)
|
343
|
+
font = column_font(col)
|
344
|
+
font && font.is_underlined
|
345
|
+
end
|
346
|
+
|
347
|
+
def is_column_struckthrough(col = 0)
|
348
|
+
font = column_font(col)
|
349
|
+
font && font.is_strikethrough
|
350
|
+
end
|
351
|
+
|
352
|
+
# Get raw column width value as stored in the file
|
353
|
+
def get_column_width_raw(column_index = 0)
|
354
|
+
validate_workbook
|
355
|
+
validate_nonnegative(column_index)
|
356
|
+
|
357
|
+
range = cols.locate_range(column_index)
|
358
|
+
range && range.width
|
359
|
+
end
|
360
|
+
|
361
|
+
# Get column width measured in number of digits, as per
|
362
|
+
# http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
|
363
|
+
def get_column_width(column_index = 0)
|
364
|
+
width = get_column_width_raw(column_index)
|
365
|
+
return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
|
366
|
+
(width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
|
367
|
+
end
|
368
|
+
|
369
|
+
# Set raw column width value
|
370
|
+
def change_column_width_raw(column_index, width)
|
371
|
+
validate_workbook
|
372
|
+
ensure_cell_exists(0, column_index)
|
373
|
+
range = cols.get_range(column_index)
|
374
|
+
range.width = width
|
375
|
+
range.custom_width = true
|
376
|
+
end
|
377
|
+
|
378
|
+
# Get column width measured in number of digits, as per
|
379
|
+
# http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
|
380
|
+
def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
|
381
|
+
change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
|
382
|
+
end
|
383
|
+
|
384
|
+
# Helper method to get the style index for a column
|
385
|
+
def get_col_style(column_index)
|
386
|
+
range = cols.locate_range(column_index)
|
387
|
+
(range && range.style_index) || 0
|
388
|
+
end
|
389
|
+
|
390
|
+
def get_column_fill(col=0)
|
391
|
+
validate_workbook
|
392
|
+
validate_nonnegative(col)
|
393
|
+
|
394
|
+
@workbook.get_fill_color(get_col_xf(col))
|
395
|
+
end
|
396
|
+
|
397
|
+
def change_column_fill(column_index, color_code = 'ffffff')
|
398
|
+
validate_workbook
|
399
|
+
RubyXL::Color.validate_color(color_code)
|
400
|
+
ensure_cell_exists(0, column_index)
|
401
|
+
|
402
|
+
cols.get_range(column_index).style_index = @workbook.modify_fill(get_col_style(column_index), color_code)
|
403
|
+
|
404
|
+
sheet_data.rows.each { |row|
|
405
|
+
next if row.nil?
|
406
|
+
c = row[column_index]
|
407
|
+
next if c.nil?
|
408
|
+
c.change_fill(color_code)
|
409
|
+
}
|
410
|
+
end
|
411
|
+
|
412
|
+
def get_column_border(col, border_direction)
|
413
|
+
validate_workbook
|
414
|
+
|
415
|
+
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
416
|
+
border = @workbook.borders[xf.border_id]
|
417
|
+
border && border.get_edge_style(border_direction)
|
418
|
+
end
|
419
|
+
|
420
|
+
def get_column_border_color(col, border_direction)
|
421
|
+
validate_workbook
|
422
|
+
|
423
|
+
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
424
|
+
border = @workbook.borders[xf.border_id]
|
425
|
+
border && border.get_edge_color(border_direction)
|
426
|
+
end
|
427
|
+
|
428
|
+
def column_font(col)
|
429
|
+
validate_workbook
|
430
|
+
|
431
|
+
@workbook.fonts[@workbook.cell_xfs[get_cols_style_index(col)].font_id]
|
432
|
+
end
|
433
|
+
|
434
|
+
def get_column_alignment(col, type)
|
435
|
+
validate_workbook
|
436
|
+
|
437
|
+
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
438
|
+
xf.alignment && xf.alignment.send(type)
|
439
|
+
end
|
440
|
+
|
441
|
+
def change_row_horizontal_alignment(row = 0, alignment = 'center')
|
442
|
+
validate_workbook
|
443
|
+
validate_nonnegative(row)
|
444
|
+
change_row_alignment(row) { |a| a.horizontal = alignment }
|
445
|
+
end
|
446
|
+
|
447
|
+
def change_row_vertical_alignment(row = 0, alignment = 'center')
|
448
|
+
validate_workbook
|
449
|
+
validate_nonnegative(row)
|
450
|
+
change_row_alignment(row) { |a| a.vertical = alignment }
|
451
|
+
end
|
452
|
+
|
453
|
+
def change_row_border(row, direction, weight)
|
454
|
+
validate_workbook
|
455
|
+
ensure_cell_exists(row)
|
456
|
+
|
457
|
+
sheet_data.rows[row].style_index = @workbook.modify_border(get_row_style(row), direction, weight)
|
458
|
+
|
459
|
+
sheet_data[row].cells.each { |c|
|
460
|
+
c.change_border(direction, weight) unless c.nil?
|
461
|
+
}
|
462
|
+
end
|
463
|
+
|
464
|
+
def change_row_border_color(row, direction, color = '000000')
|
465
|
+
validate_workbook
|
466
|
+
ensure_cell_exists(row)
|
467
|
+
Color.validate_color(color)
|
468
|
+
|
469
|
+
sheet_data.rows[row].style_index = @workbook.modify_border_color(get_row_style(row), direction, color)
|
470
|
+
|
471
|
+
sheet_data[row].cells.each { |c|
|
472
|
+
c.change_border_color(direction, color) unless c.nil?
|
473
|
+
}
|
474
|
+
end
|
475
|
+
|
476
|
+
def change_row_fill(row_index = 0, rgb = 'ffffff')
|
477
|
+
validate_workbook
|
478
|
+
ensure_cell_exists(row_index)
|
479
|
+
Color.validate_color(rgb)
|
480
|
+
|
481
|
+
sheet_data.rows[row_index].style_index = @workbook.modify_fill(get_row_style(row_index), rgb)
|
482
|
+
sheet_data[row_index].cells.each { |c| c.change_fill(rgb) unless c.nil? }
|
483
|
+
end
|
484
|
+
|
485
|
+
# Helper method to update the row styles array
|
486
|
+
# change_type - NAME or SIZE or COLOR etc
|
487
|
+
# main method to change font, called from each separate font mutator method
|
488
|
+
def change_row_font(row_index, change_type, arg, font)
|
489
|
+
validate_workbook
|
490
|
+
ensure_cell_exists(row_index)
|
491
|
+
|
492
|
+
xf = workbook.register_new_font(font, get_row_xf(row_index))
|
493
|
+
row = sheet_data[row_index]
|
494
|
+
row.style_index = workbook.register_new_xf(xf)
|
495
|
+
row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
|
496
|
+
end
|
497
|
+
|
498
|
+
def change_row_font_name(row = 0, font_name = 'Verdana')
|
499
|
+
ensure_cell_exists(row)
|
500
|
+
font = row_font(row).dup
|
501
|
+
font.set_name(font_name)
|
502
|
+
change_row_font(row, Worksheet::NAME, font_name, font)
|
503
|
+
end
|
504
|
+
|
505
|
+
def change_row_font_size(row = 0, font_size=10)
|
506
|
+
ensure_cell_exists(row)
|
507
|
+
font = row_font(row).dup
|
508
|
+
font.set_size(font_size)
|
509
|
+
change_row_font(row, Worksheet::SIZE, font_size, font)
|
510
|
+
end
|
511
|
+
|
512
|
+
def change_row_font_color(row = 0, font_color = '000000')
|
513
|
+
ensure_cell_exists(row)
|
514
|
+
Color.validate_color(font_color)
|
515
|
+
font = row_font(row).dup
|
516
|
+
font.set_rgb_color(font_color)
|
517
|
+
change_row_font(row, Worksheet::COLOR, font_color, font)
|
518
|
+
end
|
519
|
+
|
520
|
+
def change_row_italics(row = 0, italicized = false)
|
521
|
+
ensure_cell_exists(row)
|
522
|
+
font = row_font(row).dup
|
523
|
+
font.set_italic(italicized)
|
524
|
+
change_row_font(row, Worksheet::ITALICS, italicized, font)
|
525
|
+
end
|
526
|
+
|
527
|
+
def change_row_bold(row = 0, bolded = false)
|
528
|
+
ensure_cell_exists(row)
|
529
|
+
font = row_font(row).dup
|
530
|
+
font.set_bold(bolded)
|
531
|
+
change_row_font(row, Worksheet::BOLD, bolded, font)
|
532
|
+
end
|
533
|
+
|
534
|
+
def change_row_underline(row = 0, underlined=false)
|
535
|
+
ensure_cell_exists(row)
|
536
|
+
font = row_font(row).dup
|
537
|
+
font.set_underline(underlined)
|
538
|
+
change_row_font(row, Worksheet::UNDERLINE, underlined, font)
|
539
|
+
end
|
540
|
+
|
541
|
+
def change_row_strikethrough(row = 0, struckthrough=false)
|
542
|
+
ensure_cell_exists(row)
|
543
|
+
font = row_font(row).dup
|
544
|
+
font.set_strikethrough(struckthrough)
|
545
|
+
change_row_font(row, Worksheet::STRIKETHROUGH, struckthrough, font)
|
546
|
+
end
|
547
|
+
|
548
|
+
def change_row_height(row = 0, height = 10)
|
549
|
+
validate_workbook
|
550
|
+
ensure_cell_exists(row)
|
551
|
+
|
552
|
+
c = sheet_data.rows[row]
|
553
|
+
c.ht = height
|
554
|
+
c.custom_height = true
|
555
|
+
end
|
556
|
+
|
557
|
+
# Helper method to update the fonts and cell styles array
|
558
|
+
# main method to change font, called from each separate font mutator method
|
559
|
+
def change_column_font(column_index, change_type, arg, font, xf)
|
560
|
+
validate_workbook
|
561
|
+
ensure_cell_exists(0, column_index)
|
562
|
+
|
563
|
+
xf = workbook.register_new_font(font, xf)
|
564
|
+
cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
|
565
|
+
|
566
|
+
sheet_data.rows.each { |row|
|
567
|
+
c = row && row[column_index]
|
568
|
+
c.font_switch(change_type, arg) unless c.nil?
|
569
|
+
}
|
570
|
+
end
|
571
|
+
|
572
|
+
def change_column_font_name(column_index = 0, font_name = 'Verdana')
|
573
|
+
xf = get_col_xf(column_index)
|
574
|
+
font = @workbook.fonts[xf.font_id].dup
|
575
|
+
font.set_name(font_name)
|
576
|
+
change_column_font(column_index, Worksheet::NAME, font_name, font, xf)
|
577
|
+
end
|
578
|
+
|
579
|
+
def change_column_font_size(column_index, font_size=10)
|
580
|
+
xf = get_col_xf(column_index)
|
581
|
+
font = @workbook.fonts[xf.font_id].dup
|
582
|
+
font.set_size(font_size)
|
583
|
+
change_column_font(column_index, Worksheet::SIZE, font_size, font, xf)
|
584
|
+
end
|
585
|
+
|
586
|
+
def change_column_font_color(column_index, font_color='000000')
|
587
|
+
Color.validate_color(font_color)
|
588
|
+
|
589
|
+
xf = get_col_xf(column_index)
|
590
|
+
font = @workbook.fonts[xf.font_id].dup
|
591
|
+
font.set_rgb_color(font_color)
|
592
|
+
change_column_font(column_index, Worksheet::COLOR, font_color, font, xf)
|
593
|
+
end
|
594
|
+
|
595
|
+
def change_column_italics(column_index, italicized = false)
|
596
|
+
xf = get_col_xf(column_index)
|
597
|
+
font = @workbook.fonts[xf.font_id].dup
|
598
|
+
font.set_italic(italicized)
|
599
|
+
change_column_font(column_index, Worksheet::ITALICS, italicized, font, xf)
|
600
|
+
end
|
601
|
+
|
602
|
+
def change_column_bold(column_index, bolded = false)
|
603
|
+
xf = get_col_xf(column_index)
|
604
|
+
font = @workbook.fonts[xf.font_id].dup
|
605
|
+
font.set_bold(bolded)
|
606
|
+
change_column_font(column_index, Worksheet::BOLD, bolded, font, xf)
|
607
|
+
end
|
608
|
+
|
609
|
+
def change_column_underline(column_index, underlined = false)
|
610
|
+
xf = get_col_xf(column_index)
|
611
|
+
font = @workbook.fonts[xf.font_id].dup
|
612
|
+
font.set_underline(underlined)
|
613
|
+
change_column_font(column_index, Worksheet::UNDERLINE, underlined, font, xf)
|
614
|
+
end
|
615
|
+
|
616
|
+
def change_column_strikethrough(column_index, struckthrough=false)
|
617
|
+
xf = get_col_xf(column_index)
|
618
|
+
font = @workbook.fonts[xf.font_id].dup
|
619
|
+
font.set_strikethrough(struckthrough)
|
620
|
+
change_column_font(column_index, Worksheet::STRIKETHROUGH, struckthrough, font, xf)
|
621
|
+
end
|
622
|
+
|
623
|
+
def change_column_horizontal_alignment(column_index, alignment = 'center')
|
624
|
+
change_column_alignment(column_index) { |a| a.horizontal = alignment }
|
625
|
+
end
|
626
|
+
|
627
|
+
def change_column_vertical_alignment(column_index, alignment = 'center')
|
628
|
+
change_column_alignment(column_index) { |a| a.vertical = alignment }
|
629
|
+
end
|
630
|
+
|
631
|
+
def change_column_border(column_index, direction, weight)
|
632
|
+
validate_workbook
|
633
|
+
ensure_cell_exists(0, column_index)
|
634
|
+
|
635
|
+
cols.get_range(column_index).style_index = @workbook.modify_border(get_col_style(column_index), direction, weight)
|
636
|
+
|
637
|
+
sheet_data.rows.each { |row|
|
638
|
+
next if row.nil?
|
639
|
+
c = row.cells[column_index]
|
640
|
+
next if c.nil?
|
641
|
+
c.change_border(direction, weight)
|
642
|
+
}
|
643
|
+
end
|
644
|
+
|
645
|
+
def change_column_border_color(column_index, direction, color)
|
646
|
+
validate_workbook
|
647
|
+
ensure_cell_exists(0, column_index)
|
648
|
+
Color.validate_color(color)
|
649
|
+
|
650
|
+
cols.get_range(column_index).style_index = @workbook.modify_border_color(get_col_style(column_index), direction, color)
|
651
|
+
|
652
|
+
sheet_data.rows.each { |row|
|
653
|
+
c = row.cells[column_index]
|
654
|
+
c.change_border_color(direction, color) unless c.nil?
|
655
|
+
}
|
656
|
+
end
|
657
|
+
|
658
|
+
def change_row_alignment(row, &block)
|
659
|
+
validate_workbook
|
660
|
+
validate_nonnegative(row)
|
661
|
+
ensure_cell_exists(row)
|
662
|
+
|
663
|
+
sheet_data.rows[row].style_index = @workbook.modify_alignment(get_row_style(row), &block)
|
664
|
+
|
665
|
+
sheet_data[row].cells.each { |c|
|
666
|
+
next if c.nil?
|
667
|
+
c.style_index = @workbook.modify_alignment(c.style_index, &block)
|
668
|
+
}
|
669
|
+
end
|
670
|
+
|
671
|
+
def change_column_alignment(column_index, &block)
|
672
|
+
validate_workbook
|
673
|
+
ensure_cell_exists(0, column_index)
|
674
|
+
|
675
|
+
cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
|
676
|
+
# Excel gets confused if width is not explicitly set for a column that had alignment changes
|
677
|
+
change_column_width(column_index) if get_column_width_raw(column_index).nil?
|
678
|
+
|
679
|
+
sheet_data.rows.each { |row|
|
680
|
+
next if row.nil?
|
681
|
+
c = row[column_index]
|
682
|
+
next if c.nil?
|
683
|
+
c.style_index = @workbook.modify_alignment(c.style_index, &block)
|
684
|
+
}
|
685
|
+
end
|
686
|
+
|
687
|
+
# Merges cells within a rectangular area
|
688
|
+
def merge_cells(start_row, start_col, end_row, end_col)
|
689
|
+
validate_workbook
|
690
|
+
|
691
|
+
self.merged_cells ||= RubyXL::MergedCells.new
|
692
|
+
# TODO: add validation to make sure ranges are not intersecting with existing ones
|
693
|
+
merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
|
694
|
+
end
|
695
|
+
|
696
|
+
def add_validation_list(ref, list_arr)
|
697
|
+
# "Any double quote characters in the value should be escaped with another double quote.
|
698
|
+
# If the value does not contain a comma, newline or double quote, then the String value should be returned unchanged.
|
699
|
+
# If the value contains a comma, newline or double quote, then the String value should be returned enclosed in double quotes."
|
700
|
+
expr = '"' + list_arr.collect{|str| str.gsub('"', '""')}.join(',') + '"'
|
701
|
+
self.data_validations ||= RubyXL::DataValidations.new
|
702
|
+
self.data_validations <<
|
703
|
+
RubyXL::DataValidation.new({:sqref => RubyXL::Reference.new(ref),
|
704
|
+
:formula1 => RubyXL::Formula.new(:expression => expr),
|
705
|
+
:type => 'list'})
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
709
|
+
RubyXL::Worksheet.send(:include, RubyXL::WorksheetConvenienceMethods) # ruby 2.1 compat
|
710
|
+
end
|