rubyXL 3.3.33 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +12 -0
- data/VERSION +1 -1
- data/lib/rubyXL/convenience_methods.rb +5 -1301
- data/lib/rubyXL/convenience_methods/cell.rb +262 -0
- data/lib/rubyXL/convenience_methods/color.rb +158 -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 +618 -0
- data/lib/rubyXL/objects/color.rb +0 -3
- data/lib/rubyXL/objects/external_links.rb +1 -1
- data/lib/rubyXL/objects/font.rb +0 -3
- data/lib/rubyXL/objects/sheet_data.rb +0 -2
- data/lib/rubyXL/objects/workbook.rb +95 -2
- data/lib/rubyXL/objects/worksheet.rb +0 -2
- data/rdoc/README_rdoc.html +24 -1
- data/rdoc/RubyXL.html +21 -1
- data/rdoc/RubyXL/AExtension.html +1 -1
- data/rdoc/RubyXL/AExtensionStorageArea.html +1 -1
- data/rdoc/RubyXL/ActiveX.html +1 -1
- data/rdoc/RubyXL/ActiveXBinary.html +1 -1
- data/rdoc/RubyXL/AdjustHandleList.html +1 -1
- data/rdoc/RubyXL/Alignment.html +1 -1
- data/rdoc/RubyXL/AlternateContent.html +1 -1
- data/rdoc/RubyXL/Authors.html +1 -1
- data/rdoc/RubyXL/AutoFilter.html +1 -1
- data/rdoc/RubyXL/AutoFilterColumn.html +1 -1
- data/rdoc/RubyXL/BinaryImageFile.html +1 -1
- data/rdoc/RubyXL/BodyProperties.html +1 -1
- data/rdoc/RubyXL/BooleanNode.html +1 -1
- data/rdoc/RubyXL/BooleanValue.html +1 -1
- data/rdoc/RubyXL/Border.html +1 -1
- data/rdoc/RubyXL/BorderEdge.html +1 -1
- data/rdoc/RubyXL/Borders.html +1 -1
- data/rdoc/RubyXL/Break.html +1 -1
- data/rdoc/RubyXL/BreakList.html +1 -1
- data/rdoc/RubyXL/CT_AdjPoint2D.html +1 -1
- data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +1 -1
- data/rdoc/RubyXL/CT_AlphaModulateEffect.html +1 -1
- data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +1 -1
- data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +1 -1
- data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +1 -1
- data/rdoc/RubyXL/CT_Backdrop.html +1 -1
- data/rdoc/RubyXL/CT_Bevel.html +1 -1
- data/rdoc/RubyXL/CT_BiLevelEffect.html +1 -1
- data/rdoc/RubyXL/CT_BlendEffect.html +1 -1
- data/rdoc/RubyXL/CT_Blip.html +1 -1
- data/rdoc/RubyXL/CT_BlipFillProperties.html +1 -1
- data/rdoc/RubyXL/CT_BlurEffect.html +1 -1
- data/rdoc/RubyXL/CT_Camera.html +1 -1
- data/rdoc/RubyXL/CT_Color.html +1 -1
- data/rdoc/RubyXL/CT_ColorChangeEffect.html +1 -1
- data/rdoc/RubyXL/CT_ColorMapping.html +1 -1
- data/rdoc/RubyXL/CT_ColorScheme.html +1 -1
- data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +1 -1
- data/rdoc/RubyXL/CT_ConnectionSite.html +1 -1
- data/rdoc/RubyXL/CT_ConnectionSiteList.html +1 -1
- data/rdoc/RubyXL/CT_DashStop.html +1 -1
- data/rdoc/RubyXL/CT_DashStopList.html +1 -1
- data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +1 -1
- data/rdoc/RubyXL/CT_DuotoneEffect.html +1 -1
- data/rdoc/RubyXL/CT_EffectContainer.html +1 -1
- data/rdoc/RubyXL/CT_EffectList.html +1 -1
- data/rdoc/RubyXL/CT_EffectReference.html +1 -1
- data/rdoc/RubyXL/CT_EffectStyleItem.html +1 -1
- data/rdoc/RubyXL/CT_EffectStyleList.html +1 -1
- data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +1 -1
- data/rdoc/RubyXL/CT_FillEffect.html +1 -1
- data/rdoc/RubyXL/CT_FillOverlayEffect.html +1 -1
- data/rdoc/RubyXL/CT_FillStyleList.html +1 -1
- data/rdoc/RubyXL/CT_FlatText.html +1 -1
- data/rdoc/RubyXL/CT_FontCollection.html +1 -1
- data/rdoc/RubyXL/CT_FontReference.html +1 -1
- data/rdoc/RubyXL/CT_GeomGuideList.html +1 -1
- data/rdoc/RubyXL/CT_GlowEffect.html +1 -1
- data/rdoc/RubyXL/CT_GradientFillProperties.html +1 -1
- data/rdoc/RubyXL/CT_GradientStop.html +1 -1
- data/rdoc/RubyXL/CT_GradientStopList.html +1 -1
- data/rdoc/RubyXL/CT_HSLEffect.html +1 -1
- data/rdoc/RubyXL/CT_HslColor.html +1 -1
- data/rdoc/RubyXL/CT_Hyperlink.html +1 -1
- data/rdoc/RubyXL/CT_InnerShadowEffect.html +1 -1
- data/rdoc/RubyXL/CT_LightRig.html +1 -1
- data/rdoc/RubyXL/CT_LineEndProperties.html +1 -1
- data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +1 -1
- data/rdoc/RubyXL/CT_LineProperties.html +1 -1
- data/rdoc/RubyXL/CT_LineStyleList.html +1 -1
- data/rdoc/RubyXL/CT_LinearShadeProperties.html +1 -1
- data/rdoc/RubyXL/CT_LuminanceEffect.html +1 -1
- data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +1 -1
- data/rdoc/RubyXL/CT_OuterShadowEffect.html +1 -1
- data/rdoc/RubyXL/CT_Path2D.html +1 -1
- data/rdoc/RubyXL/CT_Path2DArcTo.html +1 -1
- data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +1 -1
- data/rdoc/RubyXL/CT_Path2DList.html +1 -1
- data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +1 -1
- data/rdoc/RubyXL/CT_Path2DTo.html +1 -1
- data/rdoc/RubyXL/CT_PathShadeProperties.html +1 -1
- data/rdoc/RubyXL/CT_PatternFillProperties.html +1 -1
- data/rdoc/RubyXL/CT_Point3D.html +1 -1
- data/rdoc/RubyXL/CT_PolarAdjustHandle.html +1 -1
- data/rdoc/RubyXL/CT_PresetColor.html +1 -1
- data/rdoc/RubyXL/CT_PresetLineDashProperties.html +1 -1
- data/rdoc/RubyXL/CT_PresetShadowEffect.html +1 -1
- data/rdoc/RubyXL/CT_PresetTextShape.html +1 -1
- data/rdoc/RubyXL/CT_ReflectionEffect.html +1 -1
- data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +1 -1
- data/rdoc/RubyXL/CT_RelativeRect.html +1 -1
- data/rdoc/RubyXL/CT_SRgbColor.html +1 -1
- data/rdoc/RubyXL/CT_ScRgbColor.html +1 -1
- data/rdoc/RubyXL/CT_Scene3D.html +1 -1
- data/rdoc/RubyXL/CT_SchemeColor.html +1 -1
- data/rdoc/RubyXL/CT_Shape3D.html +1 -1
- data/rdoc/RubyXL/CT_ShapeStyle.html +1 -1
- data/rdoc/RubyXL/CT_SoftEdgesEffect.html +1 -1
- data/rdoc/RubyXL/CT_SphereCoords.html +1 -1
- data/rdoc/RubyXL/CT_StretchInfoProperties.html +1 -1
- data/rdoc/RubyXL/CT_StyleMatrix.html +1 -1
- data/rdoc/RubyXL/CT_StyleMatrixReference.html +1 -1
- data/rdoc/RubyXL/CT_SupplementalFont.html +1 -1
- data/rdoc/RubyXL/CT_SystemColor.html +1 -1
- data/rdoc/RubyXL/CT_TextAutonumberBullet.html +1 -1
- data/rdoc/RubyXL/CT_TextBlipBullet.html +1 -1
- data/rdoc/RubyXL/CT_TextCharBullet.html +1 -1
- data/rdoc/RubyXL/CT_TextCharacterProperties.html +1 -1
- data/rdoc/RubyXL/CT_TextFont.html +1 -1
- data/rdoc/RubyXL/CT_TextListStyle.html +1 -1
- data/rdoc/RubyXL/CT_TextNormalAutofit.html +1 -1
- data/rdoc/RubyXL/CT_TextParagraphProperties.html +1 -1
- data/rdoc/RubyXL/CT_TextSpacing.html +1 -1
- data/rdoc/RubyXL/CT_TextTabStop.html +1 -1
- data/rdoc/RubyXL/CT_TextTabStopList.html +1 -1
- data/rdoc/RubyXL/CT_TileInfoProperties.html +1 -1
- data/rdoc/RubyXL/CT_TintEffect.html +1 -1
- data/rdoc/RubyXL/CT_Transform2D.html +1 -1
- data/rdoc/RubyXL/CT_TransformEffect.html +1 -1
- data/rdoc/RubyXL/CT_Vector3D.html +1 -1
- data/rdoc/RubyXL/CT_XYAdjustHandle.html +1 -1
- data/rdoc/RubyXL/CalculationChain.html +1 -1
- data/rdoc/RubyXL/CalculationChainCell.html +1 -1
- data/rdoc/RubyXL/CalculationProperties.html +1 -1
- data/rdoc/RubyXL/Cell.html +12 -16
- data/rdoc/RubyXL/CellConvenienceMethods.html +34 -34
- data/rdoc/RubyXL/CellExt.html +1 -1
- data/rdoc/RubyXL/CellSmartTag.html +1 -1
- data/rdoc/RubyXL/CellSmartTagProperty.html +1 -1
- data/rdoc/RubyXL/CellSmartTags.html +1 -1
- data/rdoc/RubyXL/CellStyle.html +1 -1
- data/rdoc/RubyXL/CellStyleXFs.html +1 -1
- data/rdoc/RubyXL/CellStyles.html +1 -1
- data/rdoc/RubyXL/CellValue.html +2 -2
- data/rdoc/RubyXL/CellWatch.html +1 -1
- data/rdoc/RubyXL/CellWatches.html +1 -1
- data/rdoc/RubyXL/CellXFs.html +1 -1
- data/rdoc/RubyXL/ChartColorsFile.html +1 -1
- data/rdoc/RubyXL/ChartFile.html +1 -1
- data/rdoc/RubyXL/ChartStyleFile.html +1 -1
- data/rdoc/RubyXL/ChartUserShapesFile.html +1 -1
- data/rdoc/RubyXL/Chartsheet.html +1 -1
- data/rdoc/RubyXL/ChartsheetPageSetup.html +1 -1
- data/rdoc/RubyXL/ChartsheetProperties.html +1 -1
- data/rdoc/RubyXL/ChartsheetProtection.html +1 -1
- data/rdoc/RubyXL/ChartsheetView.html +1 -1
- data/rdoc/RubyXL/ChartsheetViews.html +1 -1
- data/rdoc/RubyXL/Color.html +2 -13
- data/rdoc/RubyXL/ColorConvenienceClasses.html +1 -1
- data/rdoc/RubyXL/ColorConvenienceClasses/HlsColor.html +3 -3
- data/rdoc/RubyXL/ColorConvenienceClasses/RgbColor.html +4 -4
- data/rdoc/RubyXL/ColorConvenienceMethods.html +2 -2
- data/rdoc/RubyXL/ColorFilter.html +1 -1
- data/rdoc/RubyXL/ColorScale.html +1 -1
- data/rdoc/RubyXL/ColorSet.html +1 -1
- data/rdoc/RubyXL/Colors.html +1 -1
- data/rdoc/RubyXL/ColumnRange.html +1 -1
- data/rdoc/RubyXL/ColumnRanges.html +1 -1
- data/rdoc/RubyXL/Comment.html +1 -1
- data/rdoc/RubyXL/CommentList.html +1 -1
- data/rdoc/RubyXL/CommentsFile.html +1 -1
- data/rdoc/RubyXL/ConditionalFormatValue.html +1 -1
- data/rdoc/RubyXL/ConditionalFormatting.html +1 -1
- data/rdoc/RubyXL/ConditionalFormattingRule.html +1 -1
- data/rdoc/RubyXL/ContentTypeDefault.html +1 -1
- data/rdoc/RubyXL/ContentTypeOverride.html +1 -1
- data/rdoc/RubyXL/ContentTypes.html +1 -1
- data/rdoc/RubyXL/ControlPropertiesFile.html +1 -1
- data/rdoc/RubyXL/CorePropertiesFile.html +1 -1
- data/rdoc/RubyXL/CustomColor.html +1 -1
- data/rdoc/RubyXL/CustomColorList.html +1 -1
- data/rdoc/RubyXL/CustomFilter.html +1 -1
- data/rdoc/RubyXL/CustomFilters.html +1 -1
- data/rdoc/RubyXL/CustomGeometry.html +1 -1
- data/rdoc/RubyXL/CustomProperties.html +1 -1
- data/rdoc/RubyXL/CustomPropertiesFile.html +1 -1
- data/rdoc/RubyXL/CustomProperty.html +1 -1
- data/rdoc/RubyXL/CustomPropertyFile.html +1 -1
- data/rdoc/RubyXL/CustomSheetView.html +1 -1
- data/rdoc/RubyXL/CustomSheetViews.html +1 -1
- data/rdoc/RubyXL/CustomWorkbookView.html +1 -1
- data/rdoc/RubyXL/CustomWorkbookViews.html +1 -1
- data/rdoc/RubyXL/CustomXMLFile.html +1 -1
- data/rdoc/RubyXL/DXF.html +1 -1
- data/rdoc/RubyXL/DXFs.html +1 -1
- data/rdoc/RubyXL/DataBar.html +1 -1
- data/rdoc/RubyXL/DataConsolidate.html +1 -1
- data/rdoc/RubyXL/DataConsolidationReference.html +1 -1
- data/rdoc/RubyXL/DataConsolidationReferences.html +1 -1
- data/rdoc/RubyXL/DataType.html +1 -1
- data/rdoc/RubyXL/DataValidation.html +1 -1
- data/rdoc/RubyXL/DataValidations.html +1 -1
- data/rdoc/RubyXL/DateGroupItem.html +1 -1
- data/rdoc/RubyXL/DefinedName.html +1 -1
- data/rdoc/RubyXL/DefinedNameExt.html +1 -1
- data/rdoc/RubyXL/DefinedNames.html +1 -1
- data/rdoc/RubyXL/DefinedNamesExt.html +1 -1
- data/rdoc/RubyXL/DocumentPropertiesFile.html +1 -1
- data/rdoc/RubyXL/DrawingFile.html +1 -1
- data/rdoc/RubyXL/DynamicFilter.html +1 -1
- data/rdoc/RubyXL/EmbeddedControl.html +1 -1
- data/rdoc/RubyXL/EmbeddedControls.html +1 -1
- data/rdoc/RubyXL/Extension.html +1 -1
- data/rdoc/RubyXL/ExtensionStorageArea.html +1 -1
- data/rdoc/RubyXL/Extents.html +1 -1
- data/rdoc/RubyXL/ExternalBook.html +1 -1
- data/rdoc/RubyXL/ExternalLinksFile.html +1 -1
- data/rdoc/RubyXL/ExternalReference.html +1 -1
- data/rdoc/RubyXL/ExternalReferences.html +1 -1
- data/rdoc/RubyXL/ExtraColorSchemeList.html +1 -1
- data/rdoc/RubyXL/FieldItem.html +1 -1
- data/rdoc/RubyXL/FileRecoveryProperties.html +1 -1
- data/rdoc/RubyXL/FileSharing.html +1 -1
- data/rdoc/RubyXL/FileVersion.html +1 -1
- data/rdoc/RubyXL/Fill.html +1 -1
- data/rdoc/RubyXL/Fills.html +1 -1
- data/rdoc/RubyXL/FilterContainer.html +1 -1
- data/rdoc/RubyXL/FloatNode.html +1 -1
- data/rdoc/RubyXL/FloatValue.html +1 -1
- data/rdoc/RubyXL/Font.html +3 -14
- data/rdoc/RubyXL/FontConvenienceMethods.html +15 -15
- data/rdoc/RubyXL/FontScheme.html +1 -1
- data/rdoc/RubyXL/Fonts.html +2 -2
- data/rdoc/RubyXL/Formula.html +1 -1
- data/rdoc/RubyXL/FunctionGroup.html +1 -1
- data/rdoc/RubyXL/FunctionGroups.html +1 -1
- data/rdoc/RubyXL/GenericStorageObject.html +1 -1
- data/rdoc/RubyXL/GradientFill.html +1 -1
- data/rdoc/RubyXL/HeaderFooterSettings.html +1 -1
- data/rdoc/RubyXL/Hyperlink.html +1 -1
- data/rdoc/RubyXL/HyperlinkRelFile.html +1 -1
- data/rdoc/RubyXL/Hyperlinks.html +1 -1
- data/rdoc/RubyXL/IconFilter.html +1 -1
- data/rdoc/RubyXL/IconSet.html +1 -1
- data/rdoc/RubyXL/IgnoredError.html +1 -1
- data/rdoc/RubyXL/IgnoredErrors.html +1 -1
- data/rdoc/RubyXL/IndexedColors.html +1 -1
- data/rdoc/RubyXL/InputCells.html +1 -1
- data/rdoc/RubyXL/IntegerNode.html +1 -1
- data/rdoc/RubyXL/IntegerValue.html +1 -1
- data/rdoc/RubyXL/LegacyCell.html +1 -1
- data/rdoc/RubyXL/LegacyWorksheet.html +1 -1
- data/rdoc/RubyXL/MRUColors.html +1 -1
- data/rdoc/RubyXL/MacrosFile.html +1 -1
- data/rdoc/RubyXL/MergedCell.html +1 -1
- data/rdoc/RubyXL/MergedCells.html +1 -1
- data/rdoc/RubyXL/NumFmt.html +1 -1
- data/rdoc/RubyXL/NumberFormat.html +1 -1
- data/rdoc/RubyXL/NumberFormats.html +1 -1
- data/rdoc/RubyXL/OLEObject.html +1 -1
- data/rdoc/RubyXL/OLEObjectFile.html +1 -1
- data/rdoc/RubyXL/OLEObjects.html +1 -1
- data/rdoc/RubyXL/OLESize.html +1 -1
- data/rdoc/RubyXL/OOXMLContainerObject.html +1 -1
- data/rdoc/RubyXL/OOXMLIgnored.html +1 -1
- data/rdoc/RubyXL/OOXMLObject.html +1 -1
- data/rdoc/RubyXL/OOXMLObjectClassMethods.html +1 -1
- data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +1 -1
- data/rdoc/RubyXL/OOXMLRelationshipsFile.html +1 -1
- data/rdoc/RubyXL/OOXMLTopLevelObject.html +1 -1
- data/rdoc/RubyXL/Offset.html +1 -1
- data/rdoc/RubyXL/OutlineProperties.html +1 -1
- data/rdoc/RubyXL/PageMargins.html +1 -1
- data/rdoc/RubyXL/PageSetup.html +1 -1
- data/rdoc/RubyXL/PageSetupProperties.html +1 -1
- data/rdoc/RubyXL/Pane.html +1 -1
- data/rdoc/RubyXL/Parser.html +1 -1
- data/rdoc/RubyXL/PatternFill.html +1 -1
- data/rdoc/RubyXL/PhoneticProperties.html +1 -1
- data/rdoc/RubyXL/PhoneticRun.html +1 -1
- data/rdoc/RubyXL/PivotArea.html +1 -1
- data/rdoc/RubyXL/PivotCache.html +1 -1
- data/rdoc/RubyXL/PivotCacheDefinitionFile.html +1 -1
- data/rdoc/RubyXL/PivotCacheRecordsFile.html +1 -1
- data/rdoc/RubyXL/PivotCaches.html +1 -1
- data/rdoc/RubyXL/PivotReference.html +1 -1
- data/rdoc/RubyXL/PivotReferences.html +1 -1
- data/rdoc/RubyXL/PivotTableFile.html +1 -1
- data/rdoc/RubyXL/PivotTableSelection.html +1 -1
- data/rdoc/RubyXL/PresetGeometry.html +1 -1
- data/rdoc/RubyXL/PrintOptions.html +1 -1
- data/rdoc/RubyXL/PrinterSettingsFile.html +1 -1
- data/rdoc/RubyXL/ProtectedRange.html +1 -1
- data/rdoc/RubyXL/ProtectedRanges.html +1 -1
- data/rdoc/RubyXL/Protection.html +1 -1
- data/rdoc/RubyXL/RID.html +1 -1
- data/rdoc/RubyXL/RawOOXML.html +1 -1
- data/rdoc/RubyXL/Reference.html +1 -1
- data/rdoc/RubyXL/Relationship.html +1 -1
- data/rdoc/RubyXL/RelationshipSupport.html +1 -1
- data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +1 -1
- data/rdoc/RubyXL/RevisionPointer.html +1 -1
- data/rdoc/RubyXL/RichText.html +1 -1
- data/rdoc/RubyXL/RichTextRun.html +1 -1
- data/rdoc/RubyXL/Row.html +10 -10
- data/rdoc/RubyXL/RowExt.html +1 -1
- data/rdoc/RubyXL/RunProperties.html +1 -1
- data/rdoc/RubyXL/Scenario.html +1 -1
- data/rdoc/RubyXL/Scenarios.html +1 -1
- data/rdoc/RubyXL/Selection.html +2 -2
- data/rdoc/RubyXL/ShapeGuide.html +1 -1
- data/rdoc/RubyXL/ShapeTextRectangle.html +1 -1
- data/rdoc/RubyXL/SharedStringsTable.html +1 -1
- data/rdoc/RubyXL/Sheet.html +1 -1
- data/rdoc/RubyXL/SheetCalculationProperties.html +1 -1
- data/rdoc/RubyXL/SheetData.html +3 -3
- data/rdoc/RubyXL/SheetDataExt.html +1 -1
- data/rdoc/RubyXL/SheetDataSet.html +1 -1
- data/rdoc/RubyXL/SheetName.html +1 -1
- data/rdoc/RubyXL/SheetNames.html +1 -1
- data/rdoc/RubyXL/Sheets.html +1 -1
- data/rdoc/RubyXL/SlicerCacheFile.html +1 -1
- data/rdoc/RubyXL/SlicerFile.html +1 -1
- data/rdoc/RubyXL/SmartTagProperties.html +1 -1
- data/rdoc/RubyXL/SmartTagType.html +1 -1
- data/rdoc/RubyXL/SmartTagTypes.html +1 -1
- data/rdoc/RubyXL/SmartTags.html +1 -1
- data/rdoc/RubyXL/SortCondition.html +1 -1
- data/rdoc/RubyXL/SortState.html +1 -1
- data/rdoc/RubyXL/Sqref.html +1 -1
- data/rdoc/RubyXL/Stop.html +1 -1
- data/rdoc/RubyXL/StringNode.html +1 -1
- data/rdoc/RubyXL/StringNodeW3C.html +1 -1
- data/rdoc/RubyXL/StringValue.html +1 -1
- data/rdoc/RubyXL/Stylesheet.html +1 -1
- data/rdoc/RubyXL/TableFile.html +1 -1
- data/rdoc/RubyXL/TableParts.html +1 -1
- data/rdoc/RubyXL/TableStyle.html +1 -1
- data/rdoc/RubyXL/TableStyles.html +1 -1
- data/rdoc/RubyXL/Text.html +1 -1
- data/rdoc/RubyXL/Theme.html +1 -1
- data/rdoc/RubyXL/ThemeElements.html +1 -1
- data/rdoc/RubyXL/ThumbnailFile.html +1 -1
- data/rdoc/RubyXL/Top10.html +1 -1
- data/rdoc/RubyXL/VMLDrawingFile.html +1 -1
- data/rdoc/RubyXL/Variant.html +1 -1
- data/rdoc/RubyXL/Vector.html +1 -1
- data/rdoc/RubyXL/VectorValue.html +1 -1
- data/rdoc/RubyXL/VisualProperties.html +1 -1
- data/rdoc/RubyXL/WebPublishObject.html +1 -1
- data/rdoc/RubyXL/WebPublishObjects.html +1 -1
- data/rdoc/RubyXL/WebPublishingItem.html +1 -1
- data/rdoc/RubyXL/WebPublishingItems.html +1 -1
- data/rdoc/RubyXL/WebPublishingProperties.html +1 -1
- data/rdoc/RubyXL/Workbook.html +664 -14
- data/rdoc/RubyXL/WorkbookConvenienceMethods.html +54 -640
- data/rdoc/RubyXL/WorkbookProperties.html +1 -1
- data/rdoc/RubyXL/WorkbookProtection.html +1 -1
- data/rdoc/RubyXL/WorkbookRoot.html +1 -1
- data/rdoc/RubyXL/WorkbookView.html +1 -1
- data/rdoc/RubyXL/WorkbookViews.html +1 -1
- data/rdoc/RubyXL/Worksheet.html +5 -9
- data/rdoc/RubyXL/WorksheetConvenienceMethods.html +69 -69
- data/rdoc/RubyXL/WorksheetDimensions.html +1 -1
- data/rdoc/RubyXL/WorksheetFormatProperties.html +1 -1
- data/rdoc/RubyXL/WorksheetProperties.html +1 -1
- data/rdoc/RubyXL/WorksheetProtection.html +1 -1
- data/rdoc/RubyXL/WorksheetView.html +1 -1
- data/rdoc/RubyXL/WorksheetViews.html +1 -1
- data/rdoc/RubyXL/XF.html +1 -1
- data/rdoc/created.rid +14 -9
- data/rdoc/index.html +2 -2
- data/rdoc/js/navigation.js.gz +0 -0
- data/rdoc/js/search_index.js +1 -1
- data/rdoc/js/search_index.js.gz +0 -0
- data/rdoc/js/searcher.js.gz +0 -0
- data/rdoc/table_of_contents.html +49 -38
- data/rubyXL.gemspec +8 -3
- data/spec/lib/cell_spec.rb +2 -0
- data/spec/lib/color_spec.rb +1 -0
- data/spec/lib/workbook_spec.rb +11 -0
- data/spec/lib/worksheet_spec.rb +1 -0
- metadata +7 -2
|
@@ -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.include(RubyXL::WorkbookConvenienceMethods)
|
|
136
|
+
end
|
|
@@ -0,0 +1,618 @@
|
|
|
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
|
+
sheet_data.rows[index].cells[col] = sheet_data.rows[index-1].cells[col]
|
|
24
|
+
}
|
|
25
|
+
else
|
|
26
|
+
raise 'invalid shift option'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
return add_cell(row, col, data, formula)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# by default, only sets cell to nil
|
|
33
|
+
# if :left is specified, method will shift row contents to the right of the deleted cell to the left
|
|
34
|
+
# if :up is specified, method will shift column contents below the deleted cell upward
|
|
35
|
+
def delete_cell(row_index = 0, column_index=0, shift=nil)
|
|
36
|
+
validate_workbook
|
|
37
|
+
validate_nonnegative(row_index)
|
|
38
|
+
validate_nonnegative(column_index)
|
|
39
|
+
|
|
40
|
+
row = sheet_data[row_index]
|
|
41
|
+
old_cell = row && row[column_index]
|
|
42
|
+
|
|
43
|
+
case shift
|
|
44
|
+
when nil then
|
|
45
|
+
row.cells[column_index] = nil if row
|
|
46
|
+
when :left then
|
|
47
|
+
row.delete_cell_shift_left(column_index) if row
|
|
48
|
+
when :up then
|
|
49
|
+
(row_index...(sheet_data.size - 1)).each { |index|
|
|
50
|
+
c = sheet_data.rows[index].cells[column_index] = sheet_data.rows[index + 1].cells[column_index]
|
|
51
|
+
c.row -= 1 if c.is_a?(Cell)
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
raise 'invalid shift option'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
return old_cell
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Inserts row at row_index, pushes down, copies style from the row above (that's what Excel 2013 does!)
|
|
61
|
+
# NOTE: use of this method will break formulas which reference cells which are being "pushed down"
|
|
62
|
+
def insert_row(row_index = 0)
|
|
63
|
+
validate_workbook
|
|
64
|
+
ensure_cell_exists(row_index)
|
|
65
|
+
|
|
66
|
+
old_row = new_cells = nil
|
|
67
|
+
|
|
68
|
+
if row_index > 0 then
|
|
69
|
+
old_row = sheet_data.rows[row_index - 1]
|
|
70
|
+
if old_row then
|
|
71
|
+
new_cells = old_row.cells.collect { |c|
|
|
72
|
+
if c.nil? then nil
|
|
73
|
+
else nc = RubyXL::Cell.new(:style_index => c.style_index)
|
|
74
|
+
nc.worksheet = self
|
|
75
|
+
nc
|
|
76
|
+
end
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
row0 = sheet_data.rows[0]
|
|
82
|
+
new_cells ||= Array.new((row0 && row0.cells.size) || 0)
|
|
83
|
+
|
|
84
|
+
sheet_data.rows.insert(row_index, nil)
|
|
85
|
+
new_row = add_row(row_index, :cells => new_cells, :style_index => old_row && old_row.style_index)
|
|
86
|
+
|
|
87
|
+
# Update row values for all rows below
|
|
88
|
+
row_index.upto(sheet_data.rows.size - 1) { |r|
|
|
89
|
+
row = sheet_data.rows[r]
|
|
90
|
+
next if row.nil?
|
|
91
|
+
row.cells.each_with_index { |cell, c|
|
|
92
|
+
next if cell.nil?
|
|
93
|
+
cell.r = RubyXL::Reference.new(r, c)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return new_row
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def delete_row(row_index=0)
|
|
101
|
+
validate_workbook
|
|
102
|
+
validate_nonnegative(row_index)
|
|
103
|
+
|
|
104
|
+
deleted = sheet_data.rows.delete_at(row_index)
|
|
105
|
+
|
|
106
|
+
# Update row number of each cell
|
|
107
|
+
row_index.upto(sheet_data.size - 1) { |index|
|
|
108
|
+
row = sheet_data[index]
|
|
109
|
+
row && row.cells.each{ |c| c.row -= 1 unless c.nil? }
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return deleted
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Inserts column at +column_index+, pushes everything right, takes styles from column to left
|
|
116
|
+
# NOTE: use of this method will break formulas which reference cells which are being "pushed right"
|
|
117
|
+
def insert_column(column_index = 0)
|
|
118
|
+
validate_workbook
|
|
119
|
+
ensure_cell_exists(0, column_index)
|
|
120
|
+
|
|
121
|
+
old_range = cols.get_range(column_index)
|
|
122
|
+
|
|
123
|
+
#go through each cell in column
|
|
124
|
+
sheet_data.rows.each_with_index { |row, row_index|
|
|
125
|
+
old_cell = row[column_index]
|
|
126
|
+
c = nil
|
|
127
|
+
|
|
128
|
+
if old_cell && old_cell.style_index != 0 &&
|
|
129
|
+
old_range && old_range.style_index != old_cell.style_index then
|
|
130
|
+
|
|
131
|
+
c = RubyXL::Cell.new(:style_index => old_cell.style_index, :worksheet => self,
|
|
132
|
+
:row => row_index, :column => column_index,
|
|
133
|
+
:datatype => RubyXL::DataType::SHARED_STRING)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
row.insert_cell_shift_right(c, column_index)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
cols.insert_column(column_index)
|
|
140
|
+
|
|
141
|
+
# TODO: update column numbers
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def delete_column(column_index = 0)
|
|
145
|
+
validate_workbook
|
|
146
|
+
validate_nonnegative(column_index)
|
|
147
|
+
|
|
148
|
+
# Delete column
|
|
149
|
+
sheet_data.rows.each { |row| row.cells.delete_at(column_index) }
|
|
150
|
+
|
|
151
|
+
# Update column numbers for cells to the right of the deleted column
|
|
152
|
+
sheet_data.rows.each_with_index { |row, row_index|
|
|
153
|
+
row.cells.each_with_index { |c, ci|
|
|
154
|
+
c.column = ci if c.is_a?(Cell)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
cols.each { |range| range.delete_column(column_index) }
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def get_row_style(row_index)
|
|
162
|
+
row = sheet_data.rows[row_index]
|
|
163
|
+
(row && row.style_index) || 0
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def get_row_fill(row = 0)
|
|
167
|
+
(row = sheet_data.rows[row]) && row.get_fill_color
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def get_row_font_name(row = 0)
|
|
171
|
+
(font = row_font(row)) && font.get_name
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def get_row_font_size(row = 0)
|
|
175
|
+
(font = row_font(row)) && font.get_size
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def get_row_font_color(row = 0)
|
|
179
|
+
font = row_font(row)
|
|
180
|
+
color = font && font.color
|
|
181
|
+
color && (color.rgb || '000000')
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def is_row_italicized(row = 0)
|
|
185
|
+
(font = row_font(row)) && font.is_italic
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def is_row_bolded(row = 0)
|
|
189
|
+
(font = row_font(row)) && font.is_bold
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def is_row_underlined(row = 0)
|
|
193
|
+
(font = row_font(row)) && font.is_underlined
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def is_row_struckthrough(row = 0)
|
|
197
|
+
(font = row_font(row)) && font.is_strikethrough
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def get_row_height(row = 0)
|
|
201
|
+
validate_workbook
|
|
202
|
+
validate_nonnegative(row)
|
|
203
|
+
row = sheet_data.rows[row]
|
|
204
|
+
row && row.ht || RubyXL::Row::DEFAULT_HEIGHT
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def get_row_border(row, border_direction)
|
|
208
|
+
validate_workbook
|
|
209
|
+
|
|
210
|
+
border = @workbook.borders[get_row_xf(row).border_id]
|
|
211
|
+
border && border.get_edge_style(border_direction)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def get_row_border_color(row, border_direction)
|
|
215
|
+
validate_workbook
|
|
216
|
+
|
|
217
|
+
border = @workbook.borders[get_row_xf(row).border_id]
|
|
218
|
+
border && border.get_edge_color(border_direction)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
def row_font(row)
|
|
222
|
+
(row = sheet_data.rows[row]) && row.get_font
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def get_row_alignment(row, is_horizontal)
|
|
226
|
+
validate_workbook
|
|
227
|
+
|
|
228
|
+
xf_obj = get_row_xf(row)
|
|
229
|
+
return nil if xf_obj.alignment.nil?
|
|
230
|
+
|
|
231
|
+
if is_horizontal then return xf_obj.alignment.horizontal
|
|
232
|
+
else return xf_obj.alignment.vertical
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def get_cols_style_index(column_index)
|
|
237
|
+
validate_nonnegative(column_index)
|
|
238
|
+
range = cols.locate_range(column_index)
|
|
239
|
+
(range && range.style_index) || 0
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def get_column_font_name(col = 0)
|
|
243
|
+
font = column_font(col)
|
|
244
|
+
font && font.get_name
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def get_column_font_size(col = 0)
|
|
248
|
+
font = column_font(col)
|
|
249
|
+
font && font.get_size
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def get_column_font_color(col = 0)
|
|
253
|
+
font = column_font(col)
|
|
254
|
+
font && (font.get_rgb_color || '000000')
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def is_column_italicized(col = 0)
|
|
258
|
+
font = column_font(col)
|
|
259
|
+
font && font.is_italic
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def is_column_bolded(col = 0)
|
|
263
|
+
font = column_font(col)
|
|
264
|
+
font && font.is_bold
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def is_column_underlined(col = 0)
|
|
268
|
+
font = column_font(col)
|
|
269
|
+
font && font.is_underlined
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def is_column_struckthrough(col = 0)
|
|
273
|
+
font = column_font(col)
|
|
274
|
+
font && font.is_strikethrough
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# Get raw column width value as stored in the file
|
|
278
|
+
def get_column_width_raw(column_index = 0)
|
|
279
|
+
validate_workbook
|
|
280
|
+
validate_nonnegative(column_index)
|
|
281
|
+
|
|
282
|
+
range = cols.locate_range(column_index)
|
|
283
|
+
range && range.width
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# Get column width measured in number of digits, as per
|
|
287
|
+
# http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
|
|
288
|
+
def get_column_width(column_index = 0)
|
|
289
|
+
width = get_column_width_raw(column_index)
|
|
290
|
+
return RubyXL::ColumnRange::DEFAULT_WIDTH if width.nil?
|
|
291
|
+
(width - (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)).round
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Set raw column width value
|
|
295
|
+
def change_column_width_raw(column_index, width)
|
|
296
|
+
validate_workbook
|
|
297
|
+
ensure_cell_exists(0, column_index)
|
|
298
|
+
range = cols.get_range(column_index)
|
|
299
|
+
range.width = width
|
|
300
|
+
range.custom_width = true
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Get column width measured in number of digits, as per
|
|
304
|
+
# http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.column%28v=office.14%29.aspx
|
|
305
|
+
def change_column_width(column_index, width_in_chars = RubyXL::ColumnRange::DEFAULT_WIDTH)
|
|
306
|
+
change_column_width_raw(column_index, ((width_in_chars + (5.0 / RubyXL::Font::MAX_DIGIT_WIDTH)) * 256).to_i / 256.0)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# Helper method to get the style index for a column
|
|
310
|
+
def get_col_style(column_index)
|
|
311
|
+
range = cols.locate_range(column_index)
|
|
312
|
+
(range && range.style_index) || 0
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
def get_column_fill(col=0)
|
|
316
|
+
validate_workbook
|
|
317
|
+
validate_nonnegative(col)
|
|
318
|
+
|
|
319
|
+
@workbook.get_fill_color(get_col_xf(col))
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
def change_column_fill(column_index, color_code = 'ffffff')
|
|
323
|
+
validate_workbook
|
|
324
|
+
RubyXL::Color.validate_color(color_code)
|
|
325
|
+
ensure_cell_exists(0, column_index)
|
|
326
|
+
|
|
327
|
+
cols.get_range(column_index).style_index = @workbook.modify_fill(get_col_style(column_index), color_code)
|
|
328
|
+
|
|
329
|
+
sheet_data.rows.each { |row|
|
|
330
|
+
c = row[column_index]
|
|
331
|
+
c.change_fill(color_code) if c
|
|
332
|
+
}
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def get_column_border(col, border_direction)
|
|
336
|
+
validate_workbook
|
|
337
|
+
|
|
338
|
+
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
|
339
|
+
border = @workbook.borders[xf.border_id]
|
|
340
|
+
border && border.get_edge_style(border_direction)
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def get_column_border_color(col, border_direction)
|
|
344
|
+
validate_workbook
|
|
345
|
+
|
|
346
|
+
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
|
347
|
+
border = @workbook.borders[xf.border_id]
|
|
348
|
+
border && border.get_edge_color(border_direction)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def column_font(col)
|
|
352
|
+
validate_workbook
|
|
353
|
+
|
|
354
|
+
@workbook.fonts[@workbook.cell_xfs[get_cols_style_index(col)].font_id]
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def get_column_alignment(col, type)
|
|
358
|
+
validate_workbook
|
|
359
|
+
|
|
360
|
+
xf = @workbook.cell_xfs[get_cols_style_index(col)]
|
|
361
|
+
xf.alignment && xf.alignment.send(type)
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def change_row_horizontal_alignment(row = 0, alignment = 'center')
|
|
365
|
+
validate_workbook
|
|
366
|
+
validate_nonnegative(row)
|
|
367
|
+
change_row_alignment(row) { |a| a.horizontal = alignment }
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def change_row_vertical_alignment(row = 0, alignment = 'center')
|
|
371
|
+
validate_workbook
|
|
372
|
+
validate_nonnegative(row)
|
|
373
|
+
change_row_alignment(row) { |a| a.vertical = alignment }
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def change_row_border(row, direction, weight)
|
|
377
|
+
validate_workbook
|
|
378
|
+
ensure_cell_exists(row)
|
|
379
|
+
|
|
380
|
+
sheet_data.rows[row].style_index = @workbook.modify_border(get_row_style(row), direction, weight)
|
|
381
|
+
|
|
382
|
+
sheet_data[row].cells.each { |c|
|
|
383
|
+
c.change_border(direction, weight) unless c.nil?
|
|
384
|
+
}
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
def change_row_border_color(row, direction, color = '000000')
|
|
388
|
+
validate_workbook
|
|
389
|
+
ensure_cell_exists(row)
|
|
390
|
+
Color.validate_color(color)
|
|
391
|
+
|
|
392
|
+
sheet_data.rows[row].style_index = @workbook.modify_border_color(get_row_style(row), direction, color)
|
|
393
|
+
|
|
394
|
+
sheet_data[row].cells.each { |c|
|
|
395
|
+
c.change_border_color(direction, color) unless c.nil?
|
|
396
|
+
}
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def change_row_fill(row_index = 0, rgb = 'ffffff')
|
|
400
|
+
validate_workbook
|
|
401
|
+
ensure_cell_exists(row_index)
|
|
402
|
+
Color.validate_color(rgb)
|
|
403
|
+
|
|
404
|
+
sheet_data.rows[row_index].style_index = @workbook.modify_fill(get_row_style(row_index), rgb)
|
|
405
|
+
sheet_data[row_index].cells.each { |c| c.change_fill(rgb) unless c.nil? }
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
# Helper method to update the row styles array
|
|
409
|
+
# change_type - NAME or SIZE or COLOR etc
|
|
410
|
+
# main method to change font, called from each separate font mutator method
|
|
411
|
+
def change_row_font(row_index, change_type, arg, font)
|
|
412
|
+
validate_workbook
|
|
413
|
+
ensure_cell_exists(row_index)
|
|
414
|
+
|
|
415
|
+
xf = workbook.register_new_font(font, get_row_xf(row_index))
|
|
416
|
+
row = sheet_data[row_index]
|
|
417
|
+
row.style_index = workbook.register_new_xf(xf)
|
|
418
|
+
row.cells.each { |c| c.font_switch(change_type, arg) unless c.nil? }
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
def change_row_font_name(row = 0, font_name = 'Verdana')
|
|
422
|
+
ensure_cell_exists(row)
|
|
423
|
+
font = row_font(row).dup
|
|
424
|
+
font.set_name(font_name)
|
|
425
|
+
change_row_font(row, Worksheet::NAME, font_name, font)
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def change_row_font_size(row = 0, font_size=10)
|
|
429
|
+
ensure_cell_exists(row)
|
|
430
|
+
font = row_font(row).dup
|
|
431
|
+
font.set_size(font_size)
|
|
432
|
+
change_row_font(row, Worksheet::SIZE, font_size, font)
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
def change_row_font_color(row = 0, font_color = '000000')
|
|
436
|
+
ensure_cell_exists(row)
|
|
437
|
+
Color.validate_color(font_color)
|
|
438
|
+
font = row_font(row).dup
|
|
439
|
+
font.set_rgb_color(font_color)
|
|
440
|
+
change_row_font(row, Worksheet::COLOR, font_color, font)
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def change_row_italics(row = 0, italicized = false)
|
|
444
|
+
ensure_cell_exists(row)
|
|
445
|
+
font = row_font(row).dup
|
|
446
|
+
font.set_italic(italicized)
|
|
447
|
+
change_row_font(row, Worksheet::ITALICS, italicized, font)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def change_row_bold(row = 0, bolded = false)
|
|
451
|
+
ensure_cell_exists(row)
|
|
452
|
+
font = row_font(row).dup
|
|
453
|
+
font.set_bold(bolded)
|
|
454
|
+
change_row_font(row, Worksheet::BOLD, bolded, font)
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def change_row_underline(row = 0, underlined=false)
|
|
458
|
+
ensure_cell_exists(row)
|
|
459
|
+
font = row_font(row).dup
|
|
460
|
+
font.set_underline(underlined)
|
|
461
|
+
change_row_font(row, Worksheet::UNDERLINE, underlined, font)
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
def change_row_strikethrough(row = 0, struckthrough=false)
|
|
465
|
+
ensure_cell_exists(row)
|
|
466
|
+
font = row_font(row).dup
|
|
467
|
+
font.set_strikethrough(struckthrough)
|
|
468
|
+
change_row_font(row, Worksheet::STRIKETHROUGH, struckthrough, font)
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
def change_row_height(row = 0, height = 10)
|
|
472
|
+
validate_workbook
|
|
473
|
+
ensure_cell_exists(row)
|
|
474
|
+
|
|
475
|
+
c = sheet_data.rows[row]
|
|
476
|
+
c.ht = height
|
|
477
|
+
c.custom_height = true
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
# Helper method to update the fonts and cell styles array
|
|
481
|
+
# main method to change font, called from each separate font mutator method
|
|
482
|
+
def change_column_font(column_index, change_type, arg, font, xf)
|
|
483
|
+
validate_workbook
|
|
484
|
+
ensure_cell_exists(0, column_index)
|
|
485
|
+
|
|
486
|
+
xf = workbook.register_new_font(font, xf)
|
|
487
|
+
cols.get_range(column_index).style_index = workbook.register_new_xf(xf)
|
|
488
|
+
|
|
489
|
+
sheet_data.rows.each { |row|
|
|
490
|
+
c = row && row[column_index]
|
|
491
|
+
c.font_switch(change_type, arg) unless c.nil?
|
|
492
|
+
}
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def change_column_font_name(column_index = 0, font_name = 'Verdana')
|
|
496
|
+
xf = get_col_xf(column_index)
|
|
497
|
+
font = @workbook.fonts[xf.font_id].dup
|
|
498
|
+
font.set_name(font_name)
|
|
499
|
+
change_column_font(column_index, Worksheet::NAME, font_name, font, xf)
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
def change_column_font_size(column_index, font_size=10)
|
|
503
|
+
xf = get_col_xf(column_index)
|
|
504
|
+
font = @workbook.fonts[xf.font_id].dup
|
|
505
|
+
font.set_size(font_size)
|
|
506
|
+
change_column_font(column_index, Worksheet::SIZE, font_size, font, xf)
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
def change_column_font_color(column_index, font_color='000000')
|
|
510
|
+
Color.validate_color(font_color)
|
|
511
|
+
|
|
512
|
+
xf = get_col_xf(column_index)
|
|
513
|
+
font = @workbook.fonts[xf.font_id].dup
|
|
514
|
+
font.set_rgb_color(font_color)
|
|
515
|
+
change_column_font(column_index, Worksheet::COLOR, font_color, font, xf)
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
def change_column_italics(column_index, italicized = false)
|
|
519
|
+
xf = get_col_xf(column_index)
|
|
520
|
+
font = @workbook.fonts[xf.font_id].dup
|
|
521
|
+
font.set_italic(italicized)
|
|
522
|
+
change_column_font(column_index, Worksheet::ITALICS, italicized, font, xf)
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
def change_column_bold(column_index, bolded = false)
|
|
526
|
+
xf = get_col_xf(column_index)
|
|
527
|
+
font = @workbook.fonts[xf.font_id].dup
|
|
528
|
+
font.set_bold(bolded)
|
|
529
|
+
change_column_font(column_index, Worksheet::BOLD, bolded, font, xf)
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
def change_column_underline(column_index, underlined = false)
|
|
533
|
+
xf = get_col_xf(column_index)
|
|
534
|
+
font = @workbook.fonts[xf.font_id].dup
|
|
535
|
+
font.set_underline(underlined)
|
|
536
|
+
change_column_font(column_index, Worksheet::UNDERLINE, underlined, font, xf)
|
|
537
|
+
end
|
|
538
|
+
|
|
539
|
+
def change_column_strikethrough(column_index, struckthrough=false)
|
|
540
|
+
xf = get_col_xf(column_index)
|
|
541
|
+
font = @workbook.fonts[xf.font_id].dup
|
|
542
|
+
font.set_strikethrough(struckthrough)
|
|
543
|
+
change_column_font(column_index, Worksheet::STRIKETHROUGH, struckthrough, font, xf)
|
|
544
|
+
end
|
|
545
|
+
|
|
546
|
+
def change_column_horizontal_alignment(column_index, alignment = 'center')
|
|
547
|
+
change_column_alignment(column_index) { |a| a.horizontal = alignment }
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
def change_column_vertical_alignment(column_index, alignment = 'center')
|
|
551
|
+
change_column_alignment(column_index) { |a| a.vertical = alignment }
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
def change_column_border(column_index, direction, weight)
|
|
555
|
+
validate_workbook
|
|
556
|
+
ensure_cell_exists(0, column_index)
|
|
557
|
+
|
|
558
|
+
cols.get_range(column_index).style_index = @workbook.modify_border(get_col_style(column_index), direction, weight)
|
|
559
|
+
|
|
560
|
+
sheet_data.rows.each { |row|
|
|
561
|
+
c = row.cells[column_index]
|
|
562
|
+
c.change_border(direction, weight) unless c.nil?
|
|
563
|
+
}
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
def change_column_border_color(column_index, direction, color)
|
|
567
|
+
validate_workbook
|
|
568
|
+
ensure_cell_exists(0, column_index)
|
|
569
|
+
Color.validate_color(color)
|
|
570
|
+
|
|
571
|
+
cols.get_range(column_index).style_index = @workbook.modify_border_color(get_col_style(column_index), direction, color)
|
|
572
|
+
|
|
573
|
+
sheet_data.rows.each { |row|
|
|
574
|
+
c = row.cells[column_index]
|
|
575
|
+
c.change_border_color(direction, color) unless c.nil?
|
|
576
|
+
}
|
|
577
|
+
end
|
|
578
|
+
|
|
579
|
+
def change_row_alignment(row, &block)
|
|
580
|
+
validate_workbook
|
|
581
|
+
validate_nonnegative(row)
|
|
582
|
+
ensure_cell_exists(row)
|
|
583
|
+
|
|
584
|
+
sheet_data.rows[row].style_index = @workbook.modify_alignment(get_row_style(row), &block)
|
|
585
|
+
|
|
586
|
+
sheet_data[row].cells.each { |c|
|
|
587
|
+
next if c.nil?
|
|
588
|
+
c.style_index = @workbook.modify_alignment(c.style_index, &block)
|
|
589
|
+
}
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
def change_column_alignment(column_index, &block)
|
|
593
|
+
validate_workbook
|
|
594
|
+
ensure_cell_exists(0, column_index)
|
|
595
|
+
|
|
596
|
+
cols.get_range(column_index).style_index = @workbook.modify_alignment(get_col_style(column_index), &block)
|
|
597
|
+
# Excel gets confused if width is not explicitly set for a column that had alignment changes
|
|
598
|
+
change_column_width(column_index) if get_column_width_raw(column_index).nil?
|
|
599
|
+
|
|
600
|
+
sheet_data.rows.each { |row|
|
|
601
|
+
c = row[column_index]
|
|
602
|
+
next if c.nil?
|
|
603
|
+
c.style_index = @workbook.modify_alignment(c.style_index, &block)
|
|
604
|
+
}
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
# Merges cells within a rectangular area
|
|
608
|
+
def merge_cells(start_row, start_col, end_row, end_col)
|
|
609
|
+
validate_workbook
|
|
610
|
+
|
|
611
|
+
self.merged_cells ||= RubyXL::MergedCells.new
|
|
612
|
+
# TODO: add validation to make sure ranges are not intersecting with existing ones
|
|
613
|
+
merged_cells << RubyXL::MergedCell.new(:ref => RubyXL::Reference.new(start_row, end_row, start_col, end_col))
|
|
614
|
+
end
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
RubyXL::Worksheet.include(RubyXL::WorksheetConvenienceMethods)
|
|
618
|
+
end
|