rubyXL 3.3.29 → 3.4.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.circleci/config.yml +60 -0
- data/.rubocop.yml +124 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +11 -8
- data/LICENSE.txt +1 -1
- data/README.rdoc +57 -19
- data/Rakefile +29 -29
- data/VERSION +1 -1
- data/lib/rubyXL/cell.rb +2 -29
- 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 +137 -0
- data/lib/rubyXL/convenience_methods/worksheet.rb +734 -0
- data/lib/rubyXL/convenience_methods.rb +5 -1122
- data/lib/rubyXL/objects/border.rb +0 -3
- data/lib/rubyXL/objects/calculation_chain.rb +2 -2
- data/lib/rubyXL/objects/cell_style.rb +4 -6
- data/lib/rubyXL/objects/chartsheet.rb +8 -12
- data/lib/rubyXL/objects/color.rb +4 -6
- data/lib/rubyXL/objects/column_range.rb +16 -15
- data/lib/rubyXL/objects/comments.rb +1 -4
- data/lib/rubyXL/objects/connection.rb +175 -0
- data/lib/rubyXL/objects/container_nodes.rb +1 -5
- data/lib/rubyXL/objects/content_types.rb +3 -6
- data/lib/rubyXL/objects/data_validation.rb +2 -2
- data/lib/rubyXL/objects/document_properties.rb +12 -15
- data/lib/rubyXL/objects/extensions.rb +0 -2
- data/lib/rubyXL/objects/external_links.rb +38 -8
- data/lib/rubyXL/objects/fill.rb +2 -5
- data/lib/rubyXL/objects/filters.rb +5 -7
- data/lib/rubyXL/objects/font.rb +2 -7
- data/lib/rubyXL/objects/formula.rb +3 -5
- data/lib/rubyXL/objects/ooxml_object.rb +40 -31
- data/lib/rubyXL/objects/query_table.rb +106 -0
- data/lib/rubyXL/objects/reference.rb +26 -17
- data/lib/rubyXL/objects/relationships.rb +14 -14
- data/lib/rubyXL/objects/root.rb +0 -2
- data/lib/rubyXL/objects/shared_strings.rb +4 -7
- data/lib/rubyXL/objects/sheet_common.rb +1 -3
- data/lib/rubyXL/objects/sheet_data.rb +44 -17
- data/lib/rubyXL/objects/simple_types.rb +19 -2
- data/lib/rubyXL/objects/storage.rb +60 -49
- data/lib/rubyXL/objects/stylesheet.rb +9 -17
- data/lib/rubyXL/objects/text.rb +6 -8
- data/lib/rubyXL/objects/theme.rb +23 -9
- data/lib/rubyXL/objects/workbook.rb +144 -36
- data/lib/rubyXL/objects/worksheet.rb +48 -34
- data/lib/rubyXL/parser.rb +1 -3
- data/lib/rubyXL/worksheet.rb +86 -86
- data/lib/rubyXL.rb +1 -1
- data/rdoc/README_rdoc.html +212 -153
- data/rdoc/RubyXL/AExtension.html +33 -69
- data/rdoc/RubyXL/AExtensionStorageArea.html +12 -18
- data/rdoc/RubyXL/ActiveX.html +26 -52
- data/rdoc/RubyXL/ActiveXBinary.html +12 -23
- data/rdoc/RubyXL/AdjustHandleList.html +13 -20
- data/rdoc/RubyXL/Alignment.html +13 -20
- data/rdoc/RubyXL/AlternateContent.html +12 -18
- data/rdoc/RubyXL/AlternateUrls.html +99 -0
- data/rdoc/RubyXL/Authors.html +13 -20
- data/rdoc/RubyXL/AutoFilter.html +13 -20
- data/rdoc/RubyXL/AutoFilterColumn.html +13 -20
- data/rdoc/RubyXL/BinaryImageFile.html +12 -26
- data/rdoc/RubyXL/BodyProperties.html +13 -20
- data/rdoc/RubyXL/BooleanNode.html +12 -18
- data/rdoc/RubyXL/BooleanValue.html +12 -18
- data/rdoc/RubyXL/Border.html +49 -101
- data/rdoc/RubyXL/BorderEdge.html +32 -61
- data/rdoc/RubyXL/Borders.html +25 -44
- data/rdoc/RubyXL/Break.html +13 -20
- data/rdoc/RubyXL/BreakList.html +13 -20
- data/rdoc/RubyXL/CT_AdjPoint2D.html +13 -20
- data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +13 -20
- data/rdoc/RubyXL/CT_AlphaModulateEffect.html +13 -20
- data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +13 -20
- data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +13 -20
- data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +13 -20
- data/rdoc/RubyXL/CT_Backdrop.html +13 -20
- data/rdoc/RubyXL/CT_Bevel.html +13 -20
- data/rdoc/RubyXL/CT_BiLevelEffect.html +13 -20
- data/rdoc/RubyXL/CT_BlendEffect.html +13 -20
- data/rdoc/RubyXL/CT_Blip.html +13 -20
- data/rdoc/RubyXL/CT_BlipFillProperties.html +13 -20
- data/rdoc/RubyXL/CT_BlurEffect.html +13 -20
- data/rdoc/RubyXL/CT_Camera.html +13 -20
- data/rdoc/RubyXL/CT_Color.html +13 -20
- data/rdoc/RubyXL/CT_ColorChangeEffect.html +13 -20
- data/rdoc/RubyXL/CT_ColorMapping.html +13 -20
- data/rdoc/RubyXL/CT_ColorScheme.html +13 -20
- data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +13 -20
- data/rdoc/RubyXL/CT_ConnectionSite.html +13 -20
- data/rdoc/RubyXL/CT_ConnectionSiteList.html +13 -20
- data/rdoc/RubyXL/CT_DashStop.html +13 -20
- data/rdoc/RubyXL/CT_DashStopList.html +13 -20
- data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +13 -20
- data/rdoc/RubyXL/CT_DuotoneEffect.html +13 -20
- data/rdoc/RubyXL/CT_EffectContainer.html +13 -20
- data/rdoc/RubyXL/CT_EffectList.html +13 -20
- data/rdoc/RubyXL/CT_EffectReference.html +13 -20
- data/rdoc/RubyXL/CT_EffectStyleItem.html +13 -20
- data/rdoc/RubyXL/CT_EffectStyleList.html +13 -20
- data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +13 -20
- data/rdoc/RubyXL/CT_FillEffect.html +13 -20
- data/rdoc/RubyXL/CT_FillOverlayEffect.html +13 -20
- data/rdoc/RubyXL/CT_FillStyleList.html +13 -20
- data/rdoc/RubyXL/CT_FlatText.html +13 -20
- data/rdoc/RubyXL/CT_FontCollection.html +13 -20
- data/rdoc/RubyXL/CT_FontReference.html +13 -20
- data/rdoc/RubyXL/CT_GeomGuideList.html +13 -20
- data/rdoc/RubyXL/CT_GlowEffect.html +13 -20
- data/rdoc/RubyXL/CT_GradientFillProperties.html +13 -20
- data/rdoc/RubyXL/CT_GradientStop.html +13 -20
- data/rdoc/RubyXL/CT_GradientStopList.html +13 -20
- data/rdoc/RubyXL/CT_HSLEffect.html +13 -20
- data/rdoc/RubyXL/CT_HslColor.html +13 -20
- data/rdoc/RubyXL/CT_Hyperlink.html +13 -20
- data/rdoc/RubyXL/CT_InnerShadowEffect.html +13 -20
- data/rdoc/RubyXL/CT_LightRig.html +13 -20
- data/rdoc/RubyXL/CT_LineEndProperties.html +13 -20
- data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +13 -20
- data/rdoc/RubyXL/CT_LineProperties.html +13 -20
- data/rdoc/RubyXL/CT_LineStyleList.html +13 -20
- data/rdoc/RubyXL/CT_LinearShadeProperties.html +13 -20
- data/rdoc/RubyXL/CT_LuminanceEffect.html +13 -20
- data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +13 -20
- data/rdoc/RubyXL/CT_OuterShadowEffect.html +13 -20
- data/rdoc/RubyXL/CT_Path2D.html +13 -20
- data/rdoc/RubyXL/CT_Path2DArcTo.html +13 -20
- data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +13 -20
- data/rdoc/RubyXL/CT_Path2DList.html +13 -20
- data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +13 -20
- data/rdoc/RubyXL/CT_Path2DTo.html +13 -20
- data/rdoc/RubyXL/CT_PathShadeProperties.html +13 -20
- data/rdoc/RubyXL/CT_PatternFillProperties.html +13 -20
- data/rdoc/RubyXL/CT_Point3D.html +13 -20
- data/rdoc/RubyXL/CT_PolarAdjustHandle.html +13 -20
- data/rdoc/RubyXL/CT_PresetColor.html +13 -20
- data/rdoc/RubyXL/CT_PresetLineDashProperties.html +13 -20
- data/rdoc/RubyXL/CT_PresetShadowEffect.html +13 -20
- data/rdoc/RubyXL/CT_PresetTextShape.html +13 -20
- data/rdoc/RubyXL/CT_ReflectionEffect.html +13 -20
- data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +13 -20
- data/rdoc/RubyXL/CT_RelativeRect.html +13 -20
- data/rdoc/RubyXL/CT_SRgbColor.html +13 -20
- data/rdoc/RubyXL/CT_ScRgbColor.html +13 -20
- data/rdoc/RubyXL/CT_Scene3D.html +13 -20
- data/rdoc/RubyXL/CT_SchemeColor.html +13 -20
- data/rdoc/RubyXL/CT_Shape3D.html +13 -20
- data/rdoc/RubyXL/CT_ShapeStyle.html +13 -20
- data/rdoc/RubyXL/CT_SoftEdgesEffect.html +13 -20
- data/rdoc/RubyXL/CT_SphereCoords.html +13 -20
- data/rdoc/RubyXL/CT_StretchInfoProperties.html +13 -20
- data/rdoc/RubyXL/CT_StyleMatrix.html +13 -20
- data/rdoc/RubyXL/CT_StyleMatrixReference.html +13 -20
- data/rdoc/RubyXL/CT_SupplementalFont.html +13 -20
- data/rdoc/RubyXL/CT_SystemColor.html +13 -20
- data/rdoc/RubyXL/CT_TextAutonumberBullet.html +13 -20
- data/rdoc/RubyXL/CT_TextBlipBullet.html +13 -20
- data/rdoc/RubyXL/CT_TextCharBullet.html +13 -20
- data/rdoc/RubyXL/CT_TextCharacterProperties.html +13 -20
- data/rdoc/RubyXL/CT_TextFont.html +13 -20
- data/rdoc/RubyXL/CT_TextListStyle.html +13 -20
- data/rdoc/RubyXL/CT_TextNormalAutofit.html +13 -20
- data/rdoc/RubyXL/CT_TextParagraphProperties.html +13 -20
- data/rdoc/RubyXL/CT_TextSpacing.html +13 -20
- data/rdoc/RubyXL/CT_TextTabStop.html +13 -20
- data/rdoc/RubyXL/CT_TextTabStopList.html +13 -20
- data/rdoc/RubyXL/CT_TileInfoProperties.html +13 -20
- data/rdoc/RubyXL/CT_TintEffect.html +13 -20
- data/rdoc/RubyXL/CT_Transform2D.html +13 -20
- data/rdoc/RubyXL/CT_TransformEffect.html +13 -20
- data/rdoc/RubyXL/CT_Vector3D.html +13 -20
- data/rdoc/RubyXL/CT_XYAdjustHandle.html +13 -20
- data/rdoc/RubyXL/CalculationChain.html +23 -50
- data/rdoc/RubyXL/CalculationChainCell.html +13 -20
- data/rdoc/RubyXL/CalculationProperties.html +13 -20
- data/rdoc/RubyXL/Cell.html +210 -258
- data/rdoc/RubyXL/CellConvenienceMethods.html +438 -572
- data/rdoc/RubyXL/CellExt.html +13 -20
- data/rdoc/RubyXL/CellSmartTag.html +13 -20
- data/rdoc/RubyXL/CellSmartTagProperty.html +13 -20
- data/rdoc/RubyXL/CellSmartTags.html +13 -20
- data/rdoc/RubyXL/CellStyle.html +13 -20
- data/rdoc/RubyXL/CellStyleXFs.html +25 -44
- data/rdoc/RubyXL/CellStyles.html +25 -44
- data/rdoc/RubyXL/CellValue.html +24 -43
- data/rdoc/RubyXL/CellWatch.html +13 -20
- data/rdoc/RubyXL/CellWatches.html +13 -20
- data/rdoc/RubyXL/CellXFs.html +26 -48
- data/rdoc/RubyXL/ChartColorsFile.html +12 -26
- data/rdoc/RubyXL/ChartFile.html +25 -54
- data/rdoc/RubyXL/ChartStyleFile.html +12 -26
- data/rdoc/RubyXL/ChartUserShapesFile.html +12 -26
- data/rdoc/RubyXL/Chartsheet.html +26 -73
- data/rdoc/RubyXL/ChartsheetPageSetup.html +13 -20
- data/rdoc/RubyXL/ChartsheetProperties.html +13 -20
- data/rdoc/RubyXL/ChartsheetProtection.html +13 -20
- data/rdoc/RubyXL/ChartsheetView.html +13 -20
- data/rdoc/RubyXL/ChartsheetViews.html +13 -20
- data/rdoc/RubyXL/Color.html +24 -48
- data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +246 -0
- data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +285 -0
- data/rdoc/RubyXL/ColorConvenienceClasses.html +91 -0
- data/rdoc/RubyXL/ColorConvenienceMethods.html +139 -0
- data/rdoc/RubyXL/ColorFilter.html +13 -20
- data/rdoc/RubyXL/ColorScale.html +13 -20
- data/rdoc/RubyXL/ColorSet.html +13 -20
- data/rdoc/RubyXL/Colors.html +13 -20
- data/rdoc/RubyXL/ColumnRange.html +76 -91
- data/rdoc/RubyXL/ColumnRanges.html +54 -106
- data/rdoc/RubyXL/Comment.html +13 -20
- data/rdoc/RubyXL/CommentList.html +13 -20
- data/rdoc/RubyXL/CommentsFile.html +24 -56
- data/rdoc/RubyXL/ConditionalFormatValue.html +13 -20
- data/rdoc/RubyXL/ConditionalFormatting.html +13 -20
- data/rdoc/RubyXL/ConditionalFormattingRule.html +13 -20
- 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 +149 -0
- data/rdoc/RubyXL/ContentTypeDefault.html +12 -18
- data/rdoc/RubyXL/ContentTypeOverride.html +12 -18
- data/rdoc/RubyXL/ContentTypes.html +35 -72
- data/rdoc/RubyXL/ControlPropertiesFile.html +14 -23
- data/rdoc/RubyXL/CorePropertiesFile.html +89 -208
- data/rdoc/RubyXL/CustomColor.html +13 -20
- data/rdoc/RubyXL/CustomColorList.html +13 -20
- data/rdoc/RubyXL/CustomFilter.html +13 -20
- data/rdoc/RubyXL/CustomFilters.html +13 -20
- data/rdoc/RubyXL/CustomGeometry.html +13 -20
- data/rdoc/RubyXL/CustomProperties.html +13 -20
- data/rdoc/RubyXL/CustomPropertiesFile.html +12 -26
- data/rdoc/RubyXL/CustomProperty.html +13 -20
- data/rdoc/RubyXL/CustomPropertyFile.html +108 -0
- data/rdoc/RubyXL/CustomSheetView.html +13 -20
- data/rdoc/RubyXL/CustomSheetViews.html +13 -20
- data/rdoc/RubyXL/CustomWorkbookView.html +13 -20
- data/rdoc/RubyXL/CustomWorkbookViews.html +13 -20
- data/rdoc/RubyXL/CustomXMLFile.html +12 -23
- data/rdoc/RubyXL/DXF.html +13 -20
- data/rdoc/RubyXL/DXFs.html +13 -20
- data/rdoc/RubyXL/DataBar.html +13 -20
- data/rdoc/RubyXL/DataConsolidate.html +13 -20
- data/rdoc/RubyXL/DataConsolidationReference.html +13 -20
- data/rdoc/RubyXL/DataConsolidationReferences.html +13 -20
- data/rdoc/RubyXL/DataType.html +11 -40
- data/rdoc/RubyXL/DataValidation.html +13 -20
- data/rdoc/RubyXL/DataValidations.html +13 -20
- data/rdoc/RubyXL/DateGroupItem.html +13 -20
- data/rdoc/RubyXL/DefinedName.html +13 -20
- data/rdoc/RubyXL/DefinedNameExt.html +13 -20
- data/rdoc/RubyXL/DefinedNames.html +13 -20
- data/rdoc/RubyXL/DefinedNamesExt.html +13 -20
- data/rdoc/RubyXL/DocumentPropertiesFile.html +34 -76
- data/rdoc/RubyXL/DrawingFile.html +25 -54
- data/rdoc/RubyXL/DynamicFilter.html +13 -20
- data/rdoc/RubyXL/EmbeddedControl.html +13 -20
- data/rdoc/RubyXL/EmbeddedControls.html +13 -20
- data/rdoc/RubyXL/Extension.html +13 -20
- data/rdoc/RubyXL/ExtensionStorageArea.html +13 -20
- data/rdoc/RubyXL/Extents.html +13 -20
- data/rdoc/RubyXL/ExternalBook.html +13 -20
- data/rdoc/RubyXL/ExternalLinksFile.html +25 -54
- data/rdoc/RubyXL/ExternalReference.html +13 -20
- data/rdoc/RubyXL/ExternalReferences.html +13 -20
- data/rdoc/RubyXL/ExtraColorSchemeList.html +13 -20
- data/rdoc/RubyXL/FieldItem.html +13 -20
- data/rdoc/RubyXL/FileRecoveryProperties.html +13 -20
- data/rdoc/RubyXL/FileSharing.html +13 -20
- data/rdoc/RubyXL/FileVersion.html +13 -20
- data/rdoc/RubyXL/Fill.html +25 -44
- data/rdoc/RubyXL/Fills.html +25 -44
- data/rdoc/RubyXL/FilterContainer.html +13 -20
- data/rdoc/RubyXL/FloatNode.html +12 -18
- data/rdoc/RubyXL/FloatValue.html +12 -18
- data/rdoc/RubyXL/Font.html +28 -64
- data/rdoc/RubyXL/FontConvenienceMethods.html +133 -294
- data/rdoc/RubyXL/FontScheme.html +13 -20
- data/rdoc/RubyXL/Fonts.html +25 -44
- data/rdoc/RubyXL/Formula.html +13 -20
- data/rdoc/RubyXL/FunctionGroup.html +13 -20
- data/rdoc/RubyXL/FunctionGroups.html +13 -20
- data/rdoc/RubyXL/GenericStorageObject.html +41 -98
- data/rdoc/RubyXL/GradientFill.html +13 -20
- data/rdoc/RubyXL/HeaderFooterSettings.html +13 -20
- data/rdoc/RubyXL/Hyperlink.html +13 -20
- data/rdoc/RubyXL/HyperlinkRelFile.html +12 -23
- data/rdoc/RubyXL/Hyperlinks.html +13 -20
- data/rdoc/RubyXL/IconFilter.html +13 -20
- data/rdoc/RubyXL/IconSet.html +13 -20
- data/rdoc/RubyXL/IgnoredError.html +13 -20
- data/rdoc/RubyXL/IgnoredErrors.html +13 -20
- data/rdoc/RubyXL/IndexedColors.html +13 -20
- data/rdoc/RubyXL/InputCells.html +13 -20
- data/rdoc/RubyXL/IntegerNode.html +12 -18
- data/rdoc/RubyXL/IntegerValue.html +12 -18
- data/rdoc/RubyXL/LegacyCell.html +20 -71
- data/rdoc/RubyXL/LegacyWorksheet.html +77 -126
- data/rdoc/RubyXL/MRUColors.html +13 -20
- data/rdoc/RubyXL/MacrosFile.html +12 -26
- data/rdoc/RubyXL/MergedCell.html +13 -20
- data/rdoc/RubyXL/MergedCells.html +13 -20
- data/rdoc/RubyXL/NumFmt.html +13 -20
- data/rdoc/RubyXL/NumberFormat.html +25 -44
- data/rdoc/RubyXL/NumberFormats.html +25 -50
- data/rdoc/RubyXL/OLEObject.html +13 -20
- data/rdoc/RubyXL/OLEObjectFile.html +12 -26
- data/rdoc/RubyXL/OLEObjects.html +13 -20
- data/rdoc/RubyXL/OLESize.html +13 -20
- data/rdoc/RubyXL/OOXMLContainerObject.html +72 -157
- data/rdoc/RubyXL/OOXMLIgnored.html +32 -62
- data/rdoc/RubyXL/OOXMLObject.html +15 -26
- data/rdoc/RubyXL/OOXMLObjectClassMethods.html +126 -203
- data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +104 -226
- data/rdoc/RubyXL/OOXMLRelationshipsFile.html +109 -242
- data/rdoc/RubyXL/OOXMLTopLevelObject.html +67 -154
- data/rdoc/RubyXL/OdbcOleDbProperties.html +99 -0
- data/rdoc/RubyXL/Offset.html +13 -20
- 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 -20
- data/rdoc/RubyXL/PageMargins.html +13 -20
- data/rdoc/RubyXL/PageSetup.html +13 -20
- data/rdoc/RubyXL/PageSetupProperties.html +13 -20
- data/rdoc/RubyXL/Pane.html +13 -20
- data/rdoc/RubyXL/Parser.html +35 -65
- data/rdoc/RubyXL/PatternFill.html +13 -20
- data/rdoc/RubyXL/PersonMetadata.html +108 -0
- data/rdoc/RubyXL/PhoneticProperties.html +13 -20
- data/rdoc/RubyXL/PhoneticRun.html +13 -20
- data/rdoc/RubyXL/PivotArea.html +13 -20
- data/rdoc/RubyXL/PivotCache.html +13 -20
- data/rdoc/RubyXL/PivotCacheDefinitionFile.html +14 -31
- data/rdoc/RubyXL/PivotCacheRecordsFile.html +12 -26
- data/rdoc/RubyXL/PivotCaches.html +13 -20
- data/rdoc/RubyXL/PivotReference.html +13 -20
- data/rdoc/RubyXL/PivotReferences.html +13 -20
- data/rdoc/RubyXL/PivotTableFile.html +14 -31
- data/rdoc/RubyXL/PivotTableSelection.html +13 -20
- data/rdoc/RubyXL/PresetGeometry.html +13 -20
- data/rdoc/RubyXL/PrintOptions.html +13 -20
- data/rdoc/RubyXL/PrinterSettingsFile.html +12 -26
- data/rdoc/RubyXL/ProtectedRange.html +13 -20
- data/rdoc/RubyXL/ProtectedRanges.html +13 -20
- data/rdoc/RubyXL/Protection.html +13 -20
- data/rdoc/RubyXL/QueryParameter.html +99 -0
- data/rdoc/RubyXL/QueryParameters.html +99 -0
- data/rdoc/RubyXL/QueryTable.html +157 -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 -18
- data/rdoc/RubyXL/RawOOXML.html +33 -69
- data/rdoc/RubyXL/Reference.html +156 -286
- data/rdoc/RubyXL/Relationship.html +12 -18
- data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +20 -37
- data/rdoc/RubyXL/RelationshipSupport.html +62 -145
- data/rdoc/RubyXL/RevisionPointer.html +13 -23
- data/rdoc/RubyXL/RichText.html +27 -45
- data/rdoc/RubyXL/RichTextRun.html +24 -43
- data/rdoc/RubyXL/Row.html +88 -205
- data/rdoc/RubyXL/RowExt.html +13 -20
- data/rdoc/RubyXL/RunProperties.html +13 -20
- data/rdoc/RubyXL/Scenario.html +13 -20
- data/rdoc/RubyXL/Scenarios.html +13 -20
- data/rdoc/RubyXL/Selection.html +23 -42
- data/rdoc/RubyXL/ShapeGuide.html +13 -20
- data/rdoc/RubyXL/ShapeTextRectangle.html +13 -20
- data/rdoc/RubyXL/SharedStringsTable.html +81 -177
- data/rdoc/RubyXL/Sheet.html +13 -20
- data/rdoc/RubyXL/SheetCalculationProperties.html +13 -20
- data/rdoc/RubyXL/SheetData.html +32 -62
- data/rdoc/RubyXL/SheetDataExt.html +13 -20
- data/rdoc/RubyXL/SheetDataSet.html +13 -20
- data/rdoc/RubyXL/SheetMetadata.html +108 -0
- data/rdoc/RubyXL/SheetName.html +13 -20
- data/rdoc/RubyXL/SheetNames.html +13 -20
- data/rdoc/RubyXL/Sheets.html +13 -20
- data/rdoc/RubyXL/SlicerCacheFile.html +12 -26
- data/rdoc/RubyXL/SlicerFile.html +12 -26
- data/rdoc/RubyXL/SmartTagProperties.html +13 -20
- data/rdoc/RubyXL/SmartTagType.html +13 -20
- data/rdoc/RubyXL/SmartTagTypes.html +13 -20
- data/rdoc/RubyXL/SmartTags.html +13 -20
- data/rdoc/RubyXL/SortCondition.html +13 -20
- data/rdoc/RubyXL/SortState.html +13 -20
- data/rdoc/RubyXL/Sqref.html +33 -63
- data/rdoc/RubyXL/Stop.html +13 -20
- data/rdoc/RubyXL/StringNode.html +12 -18
- data/rdoc/RubyXL/StringNodeW3C.html +33 -63
- data/rdoc/RubyXL/StringValue.html +12 -18
- data/rdoc/RubyXL/Stylesheet.html +65 -138
- data/rdoc/RubyXL/TableFile.html +12 -26
- data/rdoc/RubyXL/TableParts.html +12 -18
- data/rdoc/RubyXL/TableStyle.html +13 -20
- data/rdoc/RubyXL/TableStyles.html +13 -20
- data/rdoc/RubyXL/Text.html +35 -76
- data/rdoc/RubyXL/TextImportSettings.html +99 -0
- data/rdoc/RubyXL/Theme.html +72 -72
- data/rdoc/RubyXL/ThemeElements.html +13 -20
- data/rdoc/RubyXL/ThumbnailFile.html +12 -26
- data/rdoc/RubyXL/Top10.html +13 -20
- data/rdoc/RubyXL/VMLDrawingFile.html +15 -33
- data/rdoc/RubyXL/Variant.html +13 -20
- data/rdoc/RubyXL/Vector.html +24 -43
- data/rdoc/RubyXL/VectorValue.html +12 -18
- data/rdoc/RubyXL/VisualProperties.html +13 -20
- data/rdoc/RubyXL/WebPublishObject.html +13 -20
- data/rdoc/RubyXL/WebPublishObjects.html +13 -20
- data/rdoc/RubyXL/WebPublishingItem.html +13 -20
- data/rdoc/RubyXL/WebPublishingItems.html +13 -20
- data/rdoc/RubyXL/WebPublishingProperties.html +13 -20
- data/rdoc/RubyXL/WebQueryProperties.html +99 -0
- data/rdoc/RubyXL/Workbook.html +581 -266
- data/rdoc/RubyXL/WorkbookConvenienceMethods.html +226 -951
- data/rdoc/RubyXL/WorkbookProperties.html +13 -20
- data/rdoc/RubyXL/WorkbookProtection.html +13 -20
- data/rdoc/RubyXL/WorkbookRoot.html +58 -135
- data/rdoc/RubyXL/WorkbookView.html +13 -20
- data/rdoc/RubyXL/WorkbookViews.html +13 -20
- data/rdoc/RubyXL/Worksheet.html +122 -137
- data/rdoc/RubyXL/WorksheetConvenienceMethods.html +717 -1373
- data/rdoc/RubyXL/WorksheetDimensions.html +13 -20
- data/rdoc/RubyXL/WorksheetFormatProperties.html +12 -18
- data/rdoc/RubyXL/WorksheetProperties.html +13 -20
- data/rdoc/RubyXL/WorksheetProtection.html +13 -20
- data/rdoc/RubyXL/WorksheetView.html +13 -20
- data/rdoc/RubyXL/WorksheetViews.html +13 -20
- data/rdoc/RubyXL/XF.html +13 -20
- data/rdoc/RubyXL.html +46 -306
- data/rdoc/created.rid +45 -38
- data/rdoc/css/rdoc.css +109 -12
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc/index.html +403 -726
- data/rdoc/js/darkfish.js +33 -97
- data/rdoc/js/navigation.js +12 -49
- data/rdoc/js/navigation.js.gz +0 -0
- data/rdoc/js/search.js +35 -34
- data/rdoc/js/search_index.js +1 -1
- data/rdoc/js/search_index.js.gz +0 -0
- data/rdoc/js/searcher.js +6 -6
- data/rdoc/js/searcher.js.gz +0 -0
- data/rdoc/table_of_contents.html +287 -45
- data/rubyXL.gemspec +77 -43
- data/spec/lib/cell_spec.rb +119 -6
- data/spec/lib/color_spec.rb +9 -1
- data/spec/lib/parser_spec.rb +28 -28
- data/spec/lib/reference_spec.rb +41 -5
- data/spec/lib/rgb_color_spec.rb +29 -0
- data/spec/lib/stylesheet_spec.rb +10 -11
- data/spec/lib/text_spec.rb +4 -6
- data/spec/lib/workbook_spec.rb +31 -8
- data/spec/lib/worksheet_spec.rb +886 -480
- data/spec/spec_helper.rb +2 -0
- data/test/test_parse_write.rb +15 -15
- metadata +76 -10
- data/rdoc/js/jquery.js +0 -4
@@ -1,1122 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# Finds worksheet by its name or numerical index
|
7
|
-
def [](ind)
|
8
|
-
case ind
|
9
|
-
when Integer then worksheets[ind]
|
10
|
-
when String then worksheets.find { |ws| ws.sheet_name == ind }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Create new simple worksheet and add it to the workbook worksheets
|
15
|
-
#
|
16
|
-
# @param [String] The name for the new worksheet
|
17
|
-
def add_worksheet(name = nil)
|
18
|
-
if name.nil? then
|
19
|
-
n = 0
|
20
|
-
|
21
|
-
begin
|
22
|
-
name = SHEET_NAME_TEMPLATE % (n += 1)
|
23
|
-
end until self[name].nil?
|
24
|
-
end
|
25
|
-
|
26
|
-
new_worksheet = Worksheet.new(:workbook => self, :sheet_name => name)
|
27
|
-
worksheets << new_worksheet
|
28
|
-
new_worksheet
|
29
|
-
end
|
30
|
-
|
31
|
-
def each
|
32
|
-
worksheets.each{ |i| yield i }
|
33
|
-
end
|
34
|
-
|
35
|
-
def date1904
|
36
|
-
workbook_properties && workbook_properties.date1904
|
37
|
-
end
|
38
|
-
|
39
|
-
def date1904=(v)
|
40
|
-
self.workbook_properties ||= RubyXL::WorkbookProperties.new
|
41
|
-
workbook_properties.date1904 = v
|
42
|
-
end
|
43
|
-
|
44
|
-
def company
|
45
|
-
root.document_properties.company && root.document_properties.company.value
|
46
|
-
end
|
47
|
-
|
48
|
-
def company=(v)
|
49
|
-
root.document_properties.company ||= StringNode.new
|
50
|
-
root.document_properties.company.value = v
|
51
|
-
end
|
52
|
-
|
53
|
-
def application
|
54
|
-
root.document_properties.application && root.document_properties.application.value
|
55
|
-
end
|
56
|
-
|
57
|
-
def application=(v)
|
58
|
-
root.document_properties.application ||= StringNode.new
|
59
|
-
root.document_properties.application.value = v
|
60
|
-
end
|
61
|
-
|
62
|
-
def appversion
|
63
|
-
root.document_properties.app_version && root.document_properties.app_version.value
|
64
|
-
end
|
65
|
-
|
66
|
-
def appversion=(v)
|
67
|
-
root.document_properties.app_version ||= StringNode.new
|
68
|
-
root.document_properties.app_version.value = v
|
69
|
-
end
|
70
|
-
|
71
|
-
def creator
|
72
|
-
root.core_properties.creator
|
73
|
-
end
|
74
|
-
|
75
|
-
def creator=(v)
|
76
|
-
root.core_properties.creator = v
|
77
|
-
end
|
78
|
-
|
79
|
-
def modifier
|
80
|
-
root.core_properties.modifier
|
81
|
-
end
|
82
|
-
|
83
|
-
def modifier=(v)
|
84
|
-
root.core_properties.modifier = v
|
85
|
-
end
|
86
|
-
|
87
|
-
def created_at
|
88
|
-
root.core_properties.created_at
|
89
|
-
end
|
90
|
-
|
91
|
-
def created_at=(v)
|
92
|
-
root.core_properties.created_at = v
|
93
|
-
end
|
94
|
-
|
95
|
-
def modified_at
|
96
|
-
root.core_properties.modified_at
|
97
|
-
end
|
98
|
-
|
99
|
-
def modified_at=(v)
|
100
|
-
root.core_properties.modified_at = v
|
101
|
-
end
|
102
|
-
|
103
|
-
def cell_xfs # Stylesheet should be pre-filled with defaults on initialize()
|
104
|
-
stylesheet.cell_xfs
|
105
|
-
end
|
106
|
-
|
107
|
-
def fonts # Stylesheet should be pre-filled with defaults on initialize()
|
108
|
-
stylesheet.fonts
|
109
|
-
end
|
110
|
-
|
111
|
-
def fills # Stylesheet should be pre-filled with defaults on initialize()
|
112
|
-
stylesheet.fills
|
113
|
-
end
|
114
|
-
|
115
|
-
def borders # Stylesheet should be pre-filled with defaults on initialize()
|
116
|
-
stylesheet.borders
|
117
|
-
end
|
118
|
-
|
119
|
-
def get_fill_color(xf)
|
120
|
-
fill = fills[xf.fill_id]
|
121
|
-
pattern = fill && fill.pattern_fill
|
122
|
-
color = pattern && pattern.fg_color
|
123
|
-
color && color.rgb || 'ffffff'
|
124
|
-
end
|
125
|
-
|
126
|
-
def register_new_fill(new_fill, old_xf)
|
127
|
-
new_xf = old_xf.dup
|
128
|
-
new_xf.apply_fill = true
|
129
|
-
new_xf.fill_id = fills.find_index { |x| x == new_fill } # Reuse existing fill, if it exists
|
130
|
-
new_xf.fill_id ||= fills.size # If this fill has never existed before, add it to collection.
|
131
|
-
fills[new_xf.fill_id] = new_fill
|
132
|
-
new_xf
|
133
|
-
end
|
134
|
-
|
135
|
-
def register_new_font(new_font, old_xf)
|
136
|
-
new_xf = old_xf.dup
|
137
|
-
new_xf.font_id = fonts.find_index { |x| x == new_font } # Reuse existing font, if it exists
|
138
|
-
new_xf.font_id ||= fonts.size # If this font has never existed before, add it to collection.
|
139
|
-
fonts[new_xf.font_id] = new_font
|
140
|
-
new_xf.apply_font = true
|
141
|
-
new_xf
|
142
|
-
end
|
143
|
-
|
144
|
-
def register_new_xf(new_xf)
|
145
|
-
new_xf_id = cell_xfs.find_index { |xf| xf == new_xf } # Reuse existing XF, if it exists
|
146
|
-
new_xf_id ||= cell_xfs.size # If this XF has never existed before, add it to collection.
|
147
|
-
cell_xfs[new_xf_id] = new_xf
|
148
|
-
new_xf_id
|
149
|
-
end
|
150
|
-
|
151
|
-
def modify_alignment(style_index, &block)
|
152
|
-
xf = cell_xfs[style_index || 0].dup
|
153
|
-
xf.alignment ||= RubyXL::Alignment.new
|
154
|
-
yield(xf.alignment)
|
155
|
-
xf.apply_alignment = true
|
156
|
-
|
157
|
-
register_new_xf(xf)
|
158
|
-
end
|
159
|
-
|
160
|
-
def modify_fill(style_index, rgb)
|
161
|
-
xf = cell_xfs[style_index || 0].dup
|
162
|
-
new_fill = RubyXL::Fill.new(:pattern_fill =>
|
163
|
-
RubyXL::PatternFill.new(:pattern_type => 'solid',
|
164
|
-
:fg_color => RubyXL::Color.new(:rgb => rgb)))
|
165
|
-
register_new_xf(register_new_fill(new_fill, xf))
|
166
|
-
end
|
167
|
-
|
168
|
-
def modify_border(style_index, direction, weight)
|
169
|
-
xf = cell_xfs[style_index || 0].dup
|
170
|
-
new_border = borders[xf.border_id || 0].dup
|
171
|
-
|
172
|
-
edge = new_border.send(direction)
|
173
|
-
new_border.send("#{direction}=", edge.dup) if edge
|
174
|
-
|
175
|
-
new_border.set_edge_style(direction, weight)
|
176
|
-
|
177
|
-
xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
|
178
|
-
xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
|
179
|
-
borders[xf.border_id] = new_border
|
180
|
-
xf.apply_border = true
|
181
|
-
|
182
|
-
register_new_xf(xf)
|
183
|
-
end
|
184
|
-
|
185
|
-
def modify_border_color(style_index, direction, color)
|
186
|
-
xf = cell_xfs[style_index || 0].dup
|
187
|
-
new_border = borders[xf.border_id || 0].dup
|
188
|
-
new_border.set_edge_color(direction, color)
|
189
|
-
|
190
|
-
xf.border_id = borders.find_index { |x| x == new_border } # Reuse existing border, if it exists
|
191
|
-
xf.border_id ||= borders.size # If this border has never existed before, add it to collection.
|
192
|
-
borders[xf.border_id] = new_border
|
193
|
-
xf.apply_border = true
|
194
|
-
|
195
|
-
register_new_xf(xf)
|
196
|
-
end
|
197
|
-
|
198
|
-
# Calculate password hash from string for use in 'password' fields.
|
199
|
-
# https://www.openoffice.org/sc/excelfileformat.pdf
|
200
|
-
def password_hash(pwd)
|
201
|
-
hsh = 0
|
202
|
-
pwd.reverse.each_char { |c|
|
203
|
-
hsh = hsh ^ c.ord
|
204
|
-
hsh = hsh << 1
|
205
|
-
hsh -= 0x7fff if hsh > 0x7fff
|
206
|
-
}
|
207
|
-
|
208
|
-
(hsh ^ pwd.length ^ 0xCE4B).to_s(16)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
|
213
|
-
module WorksheetConvenienceMethods
|
214
|
-
NAME = 0
|
215
|
-
SIZE = 1
|
216
|
-
COLOR = 2
|
217
|
-
ITALICS = 3
|
218
|
-
BOLD = 4
|
219
|
-
UNDERLINE = 5
|
220
|
-
STRIKETHROUGH = 6
|
221
|
-
|
222
|
-
def insert_cell(row = 0, col = 0, data = nil, formula = nil, shift = nil)
|
223
|
-
validate_workbook
|
224
|
-
ensure_cell_exists(row, col)
|
225
|
-
|
226
|
-
case shift
|
227
|
-
when nil then # No shifting at all
|
228
|
-
when :right then
|
229
|
-
sheet_data.rows[row].insert_cell_shift_right(nil, col)
|
230
|
-
when :down then
|
231
|
-
add_row(sheet_data.size, :cells => Array.new(sheet_data.rows[row].size))
|
232
|
-
(sheet_data.size - 1).downto(row+1) { |index|
|
233
|
-
sheet_data.rows[index].cells[col] = sheet_data.rows[index-1].cells[col]
|
234
|
-
}
|
235
|
-
else
|
236
|
-
raise 'invalid shift option'
|
237
|
-
end
|
238
|
-
|
239
|
-
return add_cell(row, col, data, formula)
|
240
|
-
end
|
241
|
-
|
242
|
-
# by default, only sets cell to nil
|
243
|
-
# if :left is specified, method will shift row contents to the right of the deleted cell to the left
|
244
|
-
# if :up is specified, method will shift column contents below the deleted cell upward
|
245
|
-
def delete_cell(row_index = 0, column_index=0, shift=nil)
|
246
|
-
validate_workbook
|
247
|
-
validate_nonnegative(row_index)
|
248
|
-
validate_nonnegative(column_index)
|
249
|
-
|
250
|
-
row = sheet_data[row_index]
|
251
|
-
old_cell = row && row[column_index]
|
252
|
-
|
253
|
-
case shift
|
254
|
-
when nil then
|
255
|
-
row.cells[column_index] = nil if row
|
256
|
-
when :left then
|
257
|
-
row.delete_cell_shift_left(column_index) if row
|
258
|
-
when :up then
|
259
|
-
(row_index...(sheet_data.size - 1)).each { |index|
|
260
|
-
c = sheet_data.rows[index].cells[column_index] = sheet_data.rows[index + 1].cells[column_index]
|
261
|
-
c.row -= 1 if c.is_a?(Cell)
|
262
|
-
}
|
263
|
-
else
|
264
|
-
raise 'invalid shift option'
|
265
|
-
end
|
266
|
-
|
267
|
-
return old_cell
|
268
|
-
end
|
269
|
-
|
270
|
-
# Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!)
|
271
|
-
# NOTE: use of this method will break formulas which reference cells which are being "pushed down"
|
272
|
-
def insert_row(row_index = 0)
|
273
|
-
validate_workbook
|
274
|
-
ensure_cell_exists(row_index)
|
275
|
-
|
276
|
-
old_row = new_cells = nil
|
277
|
-
|
278
|
-
if row_index > 0 then
|
279
|
-
old_row = sheet_data.rows[row_index - 1]
|
280
|
-
if old_row then
|
281
|
-
new_cells = old_row.cells.collect { |c|
|
282
|
-
if c.nil? then nil
|
283
|
-
else nc = RubyXL::Cell.new(:style_index => c.style_index)
|
284
|
-
nc.worksheet = self
|
285
|
-
nc
|
286
|
-
end
|
287
|
-
}
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
row0 = sheet_data.rows[0]
|
292
|
-
new_cells ||= Array.new((row0 && row0.cells.size) || 0)
|
293
|
-
|
294
|
-
sheet_data.rows.insert(row_index, nil)
|
295
|
-
new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
|
296
|
-
|
297
|
-
# Update row values for all rows below
|
298
|
-
row_index.upto(sheet_data.rows.size - 1) { |r|
|
299
|
-
row = sheet_data.rows[r]
|
300
|
-
next if row.nil?
|
301
|
-
row.cells.each_with_index { |cell, c|
|
302
|
-
next if cell.nil?
|
303
|
-
cell.r = RubyXL::Reference.new(r, c)
|
304
|
-
}
|
305
|
-
}
|
306
|
-
|
307
|
-
return new_row
|
308
|
-
end
|
309
|
-
|
310
|
-
def delete_row(row_index=0)
|
311
|
-
validate_workbook
|
312
|
-
validate_nonnegative(row_index)
|
313
|
-
|
314
|
-
deleted = sheet_data.rows.delete_at(row_index)
|
315
|
-
|
316
|
-
# Update row number of each cell
|
317
|
-
row_index.upto(sheet_data.size - 1) { |index|
|
318
|
-
row = sheet_data[index]
|
319
|
-
row && row.cells.each{ |c| c.row -= 1 unless c.nil? }
|
320
|
-
}
|
321
|
-
|
322
|
-
return deleted
|
323
|
-
end
|
324
|
-
|
325
|
-
# Inserts column at +column_index+, pushes everything right, takes styles from column to left
|
326
|
-
# NOTE: use of this method will break formulas which reference cells which are being "pushed right"
|
327
|
-
def insert_column(column_index = 0)
|
328
|
-
validate_workbook
|
329
|
-
ensure_cell_exists(0, column_index)
|
330
|
-
|
331
|
-
old_range = cols.get_range(column_index)
|
332
|
-
|
333
|
-
#go through each cell in column
|
334
|
-
sheet_data.rows.each_with_index { |row, row_index|
|
335
|
-
old_cell = row[column_index]
|
336
|
-
c = nil
|
337
|
-
|
338
|
-
if old_cell && old_cell.style_index != 0 &&
|
339
|
-
old_range && old_range.style_index != old_cell.style_index then
|
340
|
-
|
341
|
-
c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
|
342
|
-
:row => row_index, :column => column_index,
|
343
|
-
:datatype => RubyXL::DataType::SHARED_STRING)
|
344
|
-
end
|
345
|
-
|
346
|
-
row.insert_cell_shift_right(c, column_index)
|
347
|
-
}
|
348
|
-
|
349
|
-
cols.insert_column(column_index)
|
350
|
-
|
351
|
-
# TODO: update column numbers
|
352
|
-
end
|
353
|
-
|
354
|
-
def delete_column(column_index = 0)
|
355
|
-
validate_workbook
|
356
|
-
validate_nonnegative(column_index)
|
357
|
-
|
358
|
-
# Delete column
|
359
|
-
sheet_data.rows.each { |row| row.cells.delete_at(column_index) }
|
360
|
-
|
361
|
-
# Update column numbers for cells to the right of the deleted column
|
362
|
-
sheet_data.rows.each_with_index { |row, row_index|
|
363
|
-
row.cells.each_with_index { |c, ci|
|
364
|
-
c.column = ci if c.is_a?(Cell)
|
365
|
-
}
|
366
|
-
}
|
367
|
-
|
368
|
-
cols.each { |range| range.delete_column(column_index) }
|
369
|
-
end
|
370
|
-
|
371
|
-
def get_row_style(row_index)
|
372
|
-
row = sheet_data.rows[row_index]
|
373
|
-
(row && row.style_index) || 0
|
374
|
-
end
|
375
|
-
|
376
|
-
def get_row_fill(row = 0)
|
377
|
-
(row = sheet_data.rows[row]) && row.get_fill_color
|
378
|
-
end
|
379
|
-
|
380
|
-
def get_row_font_name(row = 0)
|
381
|
-
(font = row_font(row)) && font.get_name
|
382
|
-
end
|
383
|
-
|
384
|
-
def get_row_font_size(row = 0)
|
385
|
-
(font = row_font(row)) && font.get_size
|
386
|
-
end
|
387
|
-
|
388
|
-
def get_row_font_color(row = 0)
|
389
|
-
font = row_font(row)
|
390
|
-
color = font && font.color
|
391
|
-
color && (color.rgb || '000000')
|
392
|
-
end
|
393
|
-
|
394
|
-
def is_row_italicized(row = 0)
|
395
|
-
(font = row_font(row)) && font.is_italic
|
396
|
-
end
|
397
|
-
|
398
|
-
def is_row_bolded(row = 0)
|
399
|
-
(font = row_font(row)) && font.is_bold
|
400
|
-
end
|
401
|
-
|
402
|
-
def is_row_underlined(row = 0)
|
403
|
-
(font = row_font(row)) && font.is_underlined
|
404
|
-
end
|
405
|
-
|
406
|
-
def is_row_struckthrough(row = 0)
|
407
|
-
(font = row_font(row)) && font.is_strikethrough
|
408
|
-
end
|
409
|
-
|
410
|
-
def get_row_height(row = 0)
|
411
|
-
validate_workbook
|
412
|
-
validate_nonnegative(row)
|
413
|
-
row = sheet_data.rows[row]
|
414
|
-
row && row.ht || RubyXL::Row::DEFAULT_HEIGHT
|
415
|
-
end
|
416
|
-
|
417
|
-
def get_row_border(row, border_direction)
|
418
|
-
validate_workbook
|
419
|
-
|
420
|
-
border = @workbook.borders[get_row_xf(row).border_id]
|
421
|
-
border && border.get_edge_style(border_direction)
|
422
|
-
end
|
423
|
-
|
424
|
-
def get_row_border_color(row, border_direction)
|
425
|
-
validate_workbook
|
426
|
-
|
427
|
-
border = @workbook.borders[get_row_xf(row).border_id]
|
428
|
-
border && border.get_edge_color(border_direction)
|
429
|
-
end
|
430
|
-
|
431
|
-
def row_font(row)
|
432
|
-
(row = sheet_data.rows[row]) && row.get_font
|
433
|
-
end
|
434
|
-
|
435
|
-
def get_row_alignment(row, is_horizontal)
|
436
|
-
validate_workbook
|
437
|
-
|
438
|
-
xf_obj = get_row_xf(row)
|
439
|
-
return nil if xf_obj.alignment.nil?
|
440
|
-
|
441
|
-
if is_horizontal then return xf_obj.alignment.horizontal
|
442
|
-
else return xf_obj.alignment.vertical
|
443
|
-
end
|
444
|
-
end
|
445
|
-
|
446
|
-
def get_cols_style_index(column_index)
|
447
|
-
validate_nonnegative(column_index)
|
448
|
-
range = cols.locate_range(column_index)
|
449
|
-
(range && range.style_index) || 0
|
450
|
-
end
|
451
|
-
|
452
|
-
def get_column_font_name(col = 0)
|
453
|
-
font = column_font(col)
|
454
|
-
font && font.get_name
|
455
|
-
end
|
456
|
-
|
457
|
-
def get_column_font_size(col = 0)
|
458
|
-
font = column_font(col)
|
459
|
-
font && font.get_size
|
460
|
-
end
|
461
|
-
|
462
|
-
def get_column_font_color(col = 0)
|
463
|
-
font = column_font(col)
|
464
|
-
font && (font.get_rgb_color || '000000')
|
465
|
-
end
|
466
|
-
|
467
|
-
def is_column_italicized(col = 0)
|
468
|
-
font = column_font(col)
|
469
|
-
font && font.is_italic
|
470
|
-
end
|
471
|
-
|
472
|
-
def is_column_bolded(col = 0)
|
473
|
-
font = column_font(col)
|
474
|
-
font && font.is_bold
|
475
|
-
end
|
476
|
-
|
477
|
-
def is_column_underlined(col = 0)
|
478
|
-
font = column_font(col)
|
479
|
-
font && font.is_underlined
|
480
|
-
end
|
481
|
-
|
482
|
-
def is_column_struckthrough(col = 0)
|
483
|
-
font = column_font(col)
|
484
|
-
font && font.is_strikethrough
|
485
|
-
end
|
486
|
-
|
487
|
-
# Get raw column width value as stored in the file
|
488
|
-
def get_column_width_raw(column_index = 0)
|
489
|
-
validate_workbook
|
490
|
-
validate_nonnegative(column_index)
|
491
|
-
|
492
|
-
range = cols.locate_range(column_index)
|
493
|
-
range && range.width
|
494
|
-
end
|
495
|
-
|
496
|
-
# Get column width measured in number of digits, as per
|
497
|
-
# http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
|
498
|
-
def get_column_width(column_index = 0)
|
499
|
-
width = get_column_width_raw(column_index)
|
500
|
-
return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
|
501
|
-
(width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
|
502
|
-
end
|
503
|
-
|
504
|
-
# Set raw column width value
|
505
|
-
def change_column_width_raw(column_index, width)
|
506
|
-
validate_workbook
|
507
|
-
ensure_cell_exists(0, column_index)
|
508
|
-
range = cols.get_range(column_index)
|
509
|
-
range.width = width
|
510
|
-
range.custom_width = true
|
511
|
-
end
|
512
|
-
|
513
|
-
# Get column width measured in number of digits, as per
|
514
|
-
# http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
|
515
|
-
def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
|
516
|
-
change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
|
517
|
-
end
|
518
|
-
|
519
|
-
# Helper method to get the style index for a column
|
520
|
-
def get_col_style(column_index)
|
521
|
-
range = cols.locate_range(column_index)
|
522
|
-
(range && range.style_index) || 0
|
523
|
-
end
|
524
|
-
|
525
|
-
def get_column_fill(col=0)
|
526
|
-
validate_workbook
|
527
|
-
validate_nonnegative(col)
|
528
|
-
|
529
|
-
@workbook.get_fill_color(get_col_xf(col))
|
530
|
-
end
|
531
|
-
|
532
|
-
def change_column_fill(column_index, color_code = 'ffffff')
|
533
|
-
validate_workbook
|
534
|
-
RubyXL::Color.validate_color(color_code)
|
535
|
-
ensure_cell_exists(0, column_index)
|
536
|
-
|
537
|
-
cols.get_range(column_index).style_index = @workbook.modify_fill(get_col_style(column_index), color_code)
|
538
|
-
|
539
|
-
sheet_data.rows.each { |row|
|
540
|
-
c = row[column_index]
|
541
|
-
c.change_fill(color_code) if c
|
542
|
-
}
|
543
|
-
end
|
544
|
-
|
545
|
-
def get_column_border(col, border_direction)
|
546
|
-
validate_workbook
|
547
|
-
|
548
|
-
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
549
|
-
border = @workbook.borders[xf.border_id]
|
550
|
-
border && border.get_edge_style(border_direction)
|
551
|
-
end
|
552
|
-
|
553
|
-
def get_column_border_color(col, border_direction)
|
554
|
-
validate_workbook
|
555
|
-
|
556
|
-
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
557
|
-
border = @workbook.borders[xf.border_id]
|
558
|
-
border && border.get_edge_color(border_direction)
|
559
|
-
end
|
560
|
-
|
561
|
-
def column_font(col)
|
562
|
-
validate_workbook
|
563
|
-
|
564
|
-
@workbook.fonts[@workbook.cell_xfs[get_cols_style_index(col)].font_id]
|
565
|
-
end
|
566
|
-
|
567
|
-
def get_column_alignment(col, type)
|
568
|
-
validate_workbook
|
569
|
-
|
570
|
-
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
571
|
-
xf.alignment && xf.alignment.send(type)
|
572
|
-
end
|
573
|
-
|
574
|
-
def change_row_horizontal_alignment(row = 0, alignment = 'center')
|
575
|
-
validate_workbook
|
576
|
-
validate_nonnegative(row)
|
577
|
-
change_row_alignment(row) { |a| a.horizontal = alignment }
|
578
|
-
end
|
579
|
-
|
580
|
-
def change_row_vertical_alignment(row = 0, alignment = 'center')
|
581
|
-
validate_workbook
|
582
|
-
validate_nonnegative(row)
|
583
|
-
change_row_alignment(row) { |a| a.vertical = alignment }
|
584
|
-
end
|
585
|
-
|
586
|
-
def change_row_border(row, direction, weight)
|
587
|
-
validate_workbook
|
588
|
-
ensure_cell_exists(row)
|
589
|
-
|
590
|
-
sheet_data.rows[row].style_index = @workbook.modify_border(get_row_style(row), direction, weight)
|
591
|
-
|
592
|
-
sheet_data[row].cells.each { |c|
|
593
|
-
c.change_border(direction, weight) unless c.nil?
|
594
|
-
}
|
595
|
-
end
|
596
|
-
|
597
|
-
def change_row_border_color(row, direction, color = '000000')
|
598
|
-
validate_workbook
|
599
|
-
ensure_cell_exists(row)
|
600
|
-
Color.validate_color(color)
|
601
|
-
|
602
|
-
sheet_data.rows[row].style_index = @workbook.modify_border_color(get_row_style(row), direction, color)
|
603
|
-
|
604
|
-
sheet_data[row].cells.each { |c|
|
605
|
-
c.change_border_color(direction, color) unless c.nil?
|
606
|
-
}
|
607
|
-
end
|
608
|
-
|
609
|
-
def change_row_fill(row_index = 0, rgb = 'ffffff')
|
610
|
-
validate_workbook
|
611
|
-
ensure_cell_exists(row_index)
|
612
|
-
Color.validate_color(rgb)
|
613
|
-
|
614
|
-
sheet_data.rows[row_index].style_index = @workbook.modify_fill(get_row_style(row_index), rgb)
|
615
|
-
sheet_data[row_index].cells.each { |c| c.change_fill(rgb) unless c.nil? }
|
616
|
-
end
|
617
|
-
|
618
|
-
# Helper method to update the row styles array
|
619
|
-
# change_type - NAME or SIZE or COLOR etc
|
620
|
-
# main method to change font, called from each separate font mutator method
|
621
|
-
def change_row_font(row_index, change_type, arg, font)
|
622
|
-
validate_workbook
|
623
|
-
ensure_cell_exists(row_index)
|
624
|
-
|
625
|
-
xf = workbook.register_new_font(font, get_row_xf(row_index))
|
626
|
-
row = sheet_data[row_index]
|
627
|
-
row.style_index = workbook.register_new_xf(xf)
|
628
|
-
row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
|
629
|
-
end
|
630
|
-
|
631
|
-
def change_row_font_name(row = 0, font_name = 'Verdana')
|
632
|
-
ensure_cell_exists(row)
|
633
|
-
font = row_font(row).dup
|
634
|
-
font.set_name(font_name)
|
635
|
-
change_row_font(row, Worksheet::NAME, font_name, font)
|
636
|
-
end
|
637
|
-
|
638
|
-
def change_row_font_size(row = 0, font_size=10)
|
639
|
-
ensure_cell_exists(row)
|
640
|
-
font = row_font(row).dup
|
641
|
-
font.set_size(font_size)
|
642
|
-
change_row_font(row, Worksheet::SIZE, font_size, font)
|
643
|
-
end
|
644
|
-
|
645
|
-
def change_row_font_color(row = 0, font_color = '000000')
|
646
|
-
ensure_cell_exists(row)
|
647
|
-
Color.validate_color(font_color)
|
648
|
-
font = row_font(row).dup
|
649
|
-
font.set_rgb_color(font_color)
|
650
|
-
change_row_font(row, Worksheet::COLOR, font_color, font)
|
651
|
-
end
|
652
|
-
|
653
|
-
def change_row_italics(row = 0, italicized = false)
|
654
|
-
ensure_cell_exists(row)
|
655
|
-
font = row_font(row).dup
|
656
|
-
font.set_italic(italicized)
|
657
|
-
change_row_font(row, Worksheet::ITALICS, italicized, font)
|
658
|
-
end
|
659
|
-
|
660
|
-
def change_row_bold(row = 0, bolded = false)
|
661
|
-
ensure_cell_exists(row)
|
662
|
-
font = row_font(row).dup
|
663
|
-
font.set_bold(bolded)
|
664
|
-
change_row_font(row, Worksheet::BOLD, bolded, font)
|
665
|
-
end
|
666
|
-
|
667
|
-
def change_row_underline(row = 0, underlined=false)
|
668
|
-
ensure_cell_exists(row)
|
669
|
-
font = row_font(row).dup
|
670
|
-
font.set_underline(underlined)
|
671
|
-
change_row_font(row, Worksheet::UNDERLINE, underlined, font)
|
672
|
-
end
|
673
|
-
|
674
|
-
def change_row_strikethrough(row = 0, struckthrough=false)
|
675
|
-
ensure_cell_exists(row)
|
676
|
-
font = row_font(row).dup
|
677
|
-
font.set_strikethrough(struckthrough)
|
678
|
-
change_row_font(row, Worksheet::STRIKETHROUGH, struckthrough, font)
|
679
|
-
end
|
680
|
-
|
681
|
-
def change_row_height(row = 0, height = 10)
|
682
|
-
validate_workbook
|
683
|
-
ensure_cell_exists(row)
|
684
|
-
|
685
|
-
c = sheet_data.rows[row]
|
686
|
-
c.ht = height
|
687
|
-
c.custom_height = true
|
688
|
-
end
|
689
|
-
|
690
|
-
# Helper method to update the fonts and cell styles array
|
691
|
-
# main method to change font, called from each separate font mutator method
|
692
|
-
def change_column_font(column_index, change_type, arg, font, xf)
|
693
|
-
validate_workbook
|
694
|
-
ensure_cell_exists(0, column_index)
|
695
|
-
|
696
|
-
xf = workbook.register_new_font(font, xf)
|
697
|
-
cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
|
698
|
-
|
699
|
-
sheet_data.rows.each { |row|
|
700
|
-
c = row && row[column_index]
|
701
|
-
c.font_switch(change_type, arg) unless c.nil?
|
702
|
-
}
|
703
|
-
end
|
704
|
-
|
705
|
-
def change_column_font_name(column_index = 0, font_name = 'Verdana')
|
706
|
-
xf = get_col_xf(column_index)
|
707
|
-
font = @workbook.fonts[xf.font_id].dup
|
708
|
-
font.set_name(font_name)
|
709
|
-
change_column_font(column_index, Worksheet::NAME, font_name, font, xf)
|
710
|
-
end
|
711
|
-
|
712
|
-
def change_column_font_size(column_index, font_size=10)
|
713
|
-
xf = get_col_xf(column_index)
|
714
|
-
font = @workbook.fonts[xf.font_id].dup
|
715
|
-
font.set_size(font_size)
|
716
|
-
change_column_font(column_index, Worksheet::SIZE, font_size, font, xf)
|
717
|
-
end
|
718
|
-
|
719
|
-
def change_column_font_color(column_index, font_color='000000')
|
720
|
-
Color.validate_color(font_color)
|
721
|
-
|
722
|
-
xf = get_col_xf(column_index)
|
723
|
-
font = @workbook.fonts[xf.font_id].dup
|
724
|
-
font.set_rgb_color(font_color)
|
725
|
-
change_column_font(column_index, Worksheet::COLOR, font_color, font, xf)
|
726
|
-
end
|
727
|
-
|
728
|
-
def change_column_italics(column_index, italicized = false)
|
729
|
-
xf = get_col_xf(column_index)
|
730
|
-
font = @workbook.fonts[xf.font_id].dup
|
731
|
-
font.set_italic(italicized)
|
732
|
-
change_column_font(column_index, Worksheet::ITALICS, italicized, font, xf)
|
733
|
-
end
|
734
|
-
|
735
|
-
def change_column_bold(column_index, bolded = false)
|
736
|
-
xf = get_col_xf(column_index)
|
737
|
-
font = @workbook.fonts[xf.font_id].dup
|
738
|
-
font.set_bold(bolded)
|
739
|
-
change_column_font(column_index, Worksheet::BOLD, bolded, font, xf)
|
740
|
-
end
|
741
|
-
|
742
|
-
def change_column_underline(column_index, underlined = false)
|
743
|
-
xf = get_col_xf(column_index)
|
744
|
-
font = @workbook.fonts[xf.font_id].dup
|
745
|
-
font.set_underline(underlined)
|
746
|
-
change_column_font(column_index, Worksheet::UNDERLINE, underlined, font, xf)
|
747
|
-
end
|
748
|
-
|
749
|
-
def change_column_strikethrough(column_index, struckthrough=false)
|
750
|
-
xf = get_col_xf(column_index)
|
751
|
-
font = @workbook.fonts[xf.font_id].dup
|
752
|
-
font.set_strikethrough(struckthrough)
|
753
|
-
change_column_font(column_index, Worksheet::STRIKETHROUGH, struckthrough, font, xf)
|
754
|
-
end
|
755
|
-
|
756
|
-
def change_column_horizontal_alignment(column_index, alignment = 'center')
|
757
|
-
change_column_alignment(column_index) { |a| a.horizontal = alignment }
|
758
|
-
end
|
759
|
-
|
760
|
-
def change_column_vertical_alignment(column_index, alignment = 'center')
|
761
|
-
change_column_alignment(column_index) { |a| a.vertical = alignment }
|
762
|
-
end
|
763
|
-
|
764
|
-
def change_column_border(column_index, direction, weight)
|
765
|
-
validate_workbook
|
766
|
-
ensure_cell_exists(0, column_index)
|
767
|
-
|
768
|
-
cols.get_range(column_index).style_index = @workbook.modify_border(get_col_style(column_index), direction, weight)
|
769
|
-
|
770
|
-
sheet_data.rows.each { |row|
|
771
|
-
c = row.cells[column_index]
|
772
|
-
c.change_border(direction, weight) unless c.nil?
|
773
|
-
}
|
774
|
-
end
|
775
|
-
|
776
|
-
def change_column_border_color(column_index, direction, color)
|
777
|
-
validate_workbook
|
778
|
-
ensure_cell_exists(0, column_index)
|
779
|
-
Color.validate_color(color)
|
780
|
-
|
781
|
-
cols.get_range(column_index).style_index = @workbook.modify_border_color(get_col_style(column_index), direction, color)
|
782
|
-
|
783
|
-
sheet_data.rows.each { |row|
|
784
|
-
c = row.cells[column_index]
|
785
|
-
c.change_border_color(direction, color) unless c.nil?
|
786
|
-
}
|
787
|
-
end
|
788
|
-
|
789
|
-
def change_row_alignment(row, &block)
|
790
|
-
validate_workbook
|
791
|
-
validate_nonnegative(row)
|
792
|
-
ensure_cell_exists(row)
|
793
|
-
|
794
|
-
sheet_data.rows[row].style_index = @workbook.modify_alignment(get_row_style(row), &block)
|
795
|
-
|
796
|
-
sheet_data[row].cells.each { |c|
|
797
|
-
next if c.nil?
|
798
|
-
c.style_index = @workbook.modify_alignment(c.style_index, &block)
|
799
|
-
}
|
800
|
-
end
|
801
|
-
|
802
|
-
def change_column_alignment(column_index, &block)
|
803
|
-
validate_workbook
|
804
|
-
ensure_cell_exists(0, column_index)
|
805
|
-
|
806
|
-
cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
|
807
|
-
# Excel gets confused if width is not explicitly set for a column that had alignment changes
|
808
|
-
change_column_width(column_index) if get_column_width_raw(column_index).nil?
|
809
|
-
|
810
|
-
sheet_data.rows.each { |row|
|
811
|
-
c = row[column_index]
|
812
|
-
next if c.nil?
|
813
|
-
c.style_index = @workbook.modify_alignment(c.style_index, &block)
|
814
|
-
}
|
815
|
-
end
|
816
|
-
|
817
|
-
# Merges cells within a rectangular area
|
818
|
-
def merge_cells(start_row, start_col, end_row, end_col)
|
819
|
-
validate_workbook
|
820
|
-
|
821
|
-
self.merged_cells ||= RubyXL::MergedCells.new
|
822
|
-
# TODO: add validation to make sure ranges are not intersecting with existing ones
|
823
|
-
merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
|
824
|
-
end
|
825
|
-
end
|
826
|
-
|
827
|
-
module CellConvenienceMethods
|
828
|
-
|
829
|
-
def change_contents(data, formula_expression = nil)
|
830
|
-
validate_worksheet
|
831
|
-
|
832
|
-
if formula_expression then
|
833
|
-
self.datatype = nil
|
834
|
-
self.formula = RubyXL::Formula.new(:expression => formula_expression)
|
835
|
-
else
|
836
|
-
self.datatype = case data
|
837
|
-
when Date, Numeric then nil
|
838
|
-
else RubyXL::DataType::RAW_STRING
|
839
|
-
end
|
840
|
-
end
|
841
|
-
|
842
|
-
data = workbook.date_to_num(data) if data.is_a?(Date)
|
843
|
-
|
844
|
-
self.raw_value = data
|
845
|
-
end
|
846
|
-
|
847
|
-
def get_border(direction)
|
848
|
-
validate_worksheet
|
849
|
-
get_cell_border.get_edge_style(direction)
|
850
|
-
end
|
851
|
-
|
852
|
-
def get_border_color(direction)
|
853
|
-
validate_worksheet
|
854
|
-
get_cell_border.get_edge_color(direction)
|
855
|
-
end
|
856
|
-
|
857
|
-
def change_horizontal_alignment(alignment = 'center')
|
858
|
-
validate_worksheet
|
859
|
-
self.style_index = workbook.modify_alignment(self.style_index) { |a| a.horizontal = alignment }
|
860
|
-
end
|
861
|
-
|
862
|
-
def change_vertical_alignment(alignment = 'center')
|
863
|
-
validate_worksheet
|
864
|
-
self.style_index = workbook.modify_alignment(self.style_index) { |a| a.vertical = alignment }
|
865
|
-
end
|
866
|
-
|
867
|
-
def change_text_wrap(wrap = false)
|
868
|
-
validate_worksheet
|
869
|
-
self.style_index = workbook.modify_alignment(self.style_index) { |a| a.wrap_text = wrap }
|
870
|
-
end
|
871
|
-
|
872
|
-
def change_border(direction, weight)
|
873
|
-
validate_worksheet
|
874
|
-
self.style_index = workbook.modify_border(self.style_index, direction, weight)
|
875
|
-
end
|
876
|
-
|
877
|
-
def change_border_color(direction, color)
|
878
|
-
validate_worksheet
|
879
|
-
Color.validate_color(color)
|
880
|
-
self.style_index = workbook.modify_border_color(self.style_index, direction, color)
|
881
|
-
end
|
882
|
-
|
883
|
-
def is_italicized()
|
884
|
-
validate_worksheet
|
885
|
-
get_cell_font.is_italic
|
886
|
-
end
|
887
|
-
|
888
|
-
def is_bolded()
|
889
|
-
validate_worksheet
|
890
|
-
get_cell_font.is_bold
|
891
|
-
end
|
892
|
-
|
893
|
-
def is_underlined()
|
894
|
-
validate_worksheet
|
895
|
-
get_cell_font.is_underlined
|
896
|
-
end
|
897
|
-
|
898
|
-
def is_struckthrough()
|
899
|
-
validate_worksheet
|
900
|
-
get_cell_font.is_strikethrough
|
901
|
-
end
|
902
|
-
|
903
|
-
def font_name()
|
904
|
-
validate_worksheet
|
905
|
-
get_cell_font.get_name
|
906
|
-
end
|
907
|
-
|
908
|
-
def font_size()
|
909
|
-
validate_worksheet
|
910
|
-
get_cell_font.get_size
|
911
|
-
end
|
912
|
-
|
913
|
-
def font_color()
|
914
|
-
validate_worksheet
|
915
|
-
get_cell_font.get_rgb_color || '000000'
|
916
|
-
end
|
917
|
-
|
918
|
-
def fill_color()
|
919
|
-
validate_worksheet
|
920
|
-
return workbook.get_fill_color(get_cell_xf)
|
921
|
-
end
|
922
|
-
|
923
|
-
def horizontal_alignment()
|
924
|
-
validate_worksheet
|
925
|
-
xf_obj = get_cell_xf
|
926
|
-
return nil if xf_obj.alignment.nil?
|
927
|
-
xf_obj.alignment.horizontal
|
928
|
-
end
|
929
|
-
|
930
|
-
def vertical_alignment()
|
931
|
-
validate_worksheet
|
932
|
-
xf_obj = get_cell_xf
|
933
|
-
return nil if xf_obj.alignment.nil?
|
934
|
-
xf_obj.alignment.vertical
|
935
|
-
end
|
936
|
-
|
937
|
-
def text_wrap()
|
938
|
-
validate_worksheet
|
939
|
-
xf_obj = get_cell_xf
|
940
|
-
return nil if xf_obj.alignment.nil?
|
941
|
-
xf_obj.alignment.wrap_text
|
942
|
-
end
|
943
|
-
|
944
|
-
def set_number_format(format_code)
|
945
|
-
new_xf = get_cell_xf.dup
|
946
|
-
new_xf.num_fmt_id = workbook.stylesheet.register_number_format(format_code)
|
947
|
-
new_xf.apply_number_format = true
|
948
|
-
self.style_index = workbook.register_new_xf(new_xf)
|
949
|
-
end
|
950
|
-
|
951
|
-
# Changes fill color of cell
|
952
|
-
def change_fill(rgb = 'ffffff')
|
953
|
-
validate_worksheet
|
954
|
-
Color.validate_color(rgb)
|
955
|
-
self.style_index = workbook.modify_fill(self.style_index, rgb)
|
956
|
-
end
|
957
|
-
|
958
|
-
# Changes font name of cell
|
959
|
-
def change_font_name(new_font_name = 'Verdana')
|
960
|
-
validate_worksheet
|
961
|
-
|
962
|
-
font = get_cell_font.dup
|
963
|
-
font.set_name(new_font_name)
|
964
|
-
update_font_references(font)
|
965
|
-
end
|
966
|
-
|
967
|
-
# Changes font size of cell
|
968
|
-
def change_font_size(font_size = 10)
|
969
|
-
validate_worksheet
|
970
|
-
raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)
|
971
|
-
|
972
|
-
font = get_cell_font.dup
|
973
|
-
font.set_size(font_size)
|
974
|
-
update_font_references(font)
|
975
|
-
end
|
976
|
-
|
977
|
-
# Changes font color of cell
|
978
|
-
def change_font_color(font_color = '000000')
|
979
|
-
validate_worksheet
|
980
|
-
Color.validate_color(font_color)
|
981
|
-
|
982
|
-
font = get_cell_font.dup
|
983
|
-
font.set_rgb_color(font_color)
|
984
|
-
update_font_references(font)
|
985
|
-
end
|
986
|
-
|
987
|
-
# Changes font italics settings of cell
|
988
|
-
def change_font_italics(italicized = false)
|
989
|
-
validate_worksheet
|
990
|
-
|
991
|
-
font = get_cell_font.dup
|
992
|
-
font.set_italic(italicized)
|
993
|
-
update_font_references(font)
|
994
|
-
end
|
995
|
-
|
996
|
-
# Changes font bold settings of cell
|
997
|
-
def change_font_bold(bolded = false)
|
998
|
-
validate_worksheet
|
999
|
-
|
1000
|
-
font = get_cell_font.dup
|
1001
|
-
font.set_bold(bolded)
|
1002
|
-
update_font_references(font)
|
1003
|
-
end
|
1004
|
-
|
1005
|
-
# Changes font underline settings of cell
|
1006
|
-
def change_font_underline(underlined = false)
|
1007
|
-
validate_worksheet
|
1008
|
-
|
1009
|
-
font = get_cell_font.dup
|
1010
|
-
font.set_underline(underlined)
|
1011
|
-
update_font_references(font)
|
1012
|
-
end
|
1013
|
-
|
1014
|
-
def change_font_strikethrough(struckthrough = false)
|
1015
|
-
validate_worksheet
|
1016
|
-
|
1017
|
-
font = get_cell_font.dup
|
1018
|
-
font.set_strikethrough(struckthrough)
|
1019
|
-
update_font_references(font)
|
1020
|
-
end
|
1021
|
-
|
1022
|
-
# Helper method to update the font array and xf array
|
1023
|
-
def update_font_references(modified_font)
|
1024
|
-
xf = workbook.register_new_font(modified_font, get_cell_xf)
|
1025
|
-
self.style_index = workbook.register_new_xf(xf)
|
1026
|
-
end
|
1027
|
-
private :update_font_references
|
1028
|
-
|
1029
|
-
# Performs correct modification based on what type of change_type is specified
|
1030
|
-
def font_switch(change_type, arg)
|
1031
|
-
case change_type
|
1032
|
-
when Worksheet::NAME then change_font_name(arg)
|
1033
|
-
when Worksheet::SIZE then change_font_size(arg)
|
1034
|
-
when Worksheet::COLOR then change_font_color(arg)
|
1035
|
-
when Worksheet::ITALICS then change_font_italics(arg)
|
1036
|
-
when Worksheet::BOLD then change_font_bold(arg)
|
1037
|
-
when Worksheet::UNDERLINE then change_font_underline(arg)
|
1038
|
-
when Worksheet::STRIKETHROUGH then change_font_strikethrough(arg)
|
1039
|
-
else raise 'Invalid change_type'
|
1040
|
-
end
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
=begin
|
1044
|
-
def add_hyperlink(l)
|
1045
|
-
worksheet.hyperlinks ||= RubyXL::Hyperlinks.new
|
1046
|
-
worksheet.hyperlinks << RubyXL::Hyperlink.new(:ref => self.r, :location => l)
|
1047
|
-
# define_attribute(:'r:id', :string)
|
1048
|
-
# define_attribute(:location, :string)
|
1049
|
-
# define_attribute(:tooltip, :string)
|
1050
|
-
# define_attribute(:display, :string)
|
1051
|
-
|
1052
|
-
end
|
1053
|
-
|
1054
|
-
def add_shared_string(str)
|
1055
|
-
self.datatype = RubyXL::DataType::SHARED_STRING
|
1056
|
-
self.raw_value = @workbook.shared_strings_container.add(str)
|
1057
|
-
end
|
1058
|
-
=end
|
1059
|
-
|
1060
|
-
end
|
1061
|
-
|
1062
|
-
module FontConvenienceMethods
|
1063
|
-
# Funny enough, but presence of <i> without value (equivalent to `val == nul`) means "italic = true"!
|
1064
|
-
# Same is true for bold, strikethrough, etc
|
1065
|
-
def is_italic
|
1066
|
-
i && (i.val != false)
|
1067
|
-
end
|
1068
|
-
|
1069
|
-
def is_bold
|
1070
|
-
b && (b.val != false)
|
1071
|
-
end
|
1072
|
-
|
1073
|
-
def is_underlined
|
1074
|
-
u && (u.val != false)
|
1075
|
-
end
|
1076
|
-
|
1077
|
-
def is_strikethrough
|
1078
|
-
strike && (strike.val != false)
|
1079
|
-
end
|
1080
|
-
|
1081
|
-
def get_name
|
1082
|
-
name && name.val
|
1083
|
-
end
|
1084
|
-
|
1085
|
-
def get_size
|
1086
|
-
sz && sz.val
|
1087
|
-
end
|
1088
|
-
|
1089
|
-
def get_rgb_color
|
1090
|
-
color && color.rgb
|
1091
|
-
end
|
1092
|
-
|
1093
|
-
def set_italic(val)
|
1094
|
-
self.i = RubyXL::BooleanValue.new(:val => val)
|
1095
|
-
end
|
1096
|
-
|
1097
|
-
def set_bold(val)
|
1098
|
-
self.b = RubyXL::BooleanValue.new(:val => val)
|
1099
|
-
end
|
1100
|
-
|
1101
|
-
def set_underline(val)
|
1102
|
-
self.u = RubyXL::BooleanValue.new(:val => val)
|
1103
|
-
end
|
1104
|
-
|
1105
|
-
def set_strikethrough(val)
|
1106
|
-
self.strike = RubyXL::BooleanValue.new(:val => val)
|
1107
|
-
end
|
1108
|
-
|
1109
|
-
def set_name(val)
|
1110
|
-
self.name = RubyXL::StringValue.new(:val => val)
|
1111
|
-
end
|
1112
|
-
|
1113
|
-
def set_size(val)
|
1114
|
-
self.sz = RubyXL::FloatValue.new(:val => val)
|
1115
|
-
end
|
1116
|
-
|
1117
|
-
def set_rgb_color(font_color)
|
1118
|
-
self.color = RubyXL::Color.new(:rgb => font_color.to_s)
|
1119
|
-
end
|
1120
|
-
end
|
1121
|
-
|
1122
|
-
end
|
1
|
+
require 'rubyXL/convenience_methods/workbook'
|
2
|
+
require 'rubyXL/convenience_methods/worksheet'
|
3
|
+
require 'rubyXL/convenience_methods/cell'
|
4
|
+
require 'rubyXL/convenience_methods/font'
|
5
|
+
require 'rubyXL/convenience_methods/color'
|