rubyXL-ptr 3.3.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +229 -0
- data/Rakefile +103 -0
- data/VERSION +1 -0
- data/lib/rubyXL.rb +12 -0
- data/lib/rubyXL/cell.rb +54 -0
- data/lib/rubyXL/convenience_methods.rb +1122 -0
- data/lib/rubyXL/objects/border.rb +74 -0
- data/lib/rubyXL/objects/calculation_chain.rb +31 -0
- data/lib/rubyXL/objects/cell_style.rb +65 -0
- data/lib/rubyXL/objects/chartsheet.rb +92 -0
- data/lib/rubyXL/objects/color.rb +27 -0
- data/lib/rubyXL/objects/column_range.rb +92 -0
- data/lib/rubyXL/objects/comments.rb +47 -0
- data/lib/rubyXL/objects/container_nodes.rb +135 -0
- data/lib/rubyXL/objects/content_types.rb +77 -0
- data/lib/rubyXL/objects/data_validation.rb +37 -0
- data/lib/rubyXL/objects/document_properties.rb +159 -0
- data/lib/rubyXL/objects/extensions.rb +40 -0
- data/lib/rubyXL/objects/external_links.rb +85 -0
- data/lib/rubyXL/objects/fill.rb +55 -0
- data/lib/rubyXL/objects/filters.rb +120 -0
- data/lib/rubyXL/objects/font.rb +48 -0
- data/lib/rubyXL/objects/formula.rb +24 -0
- data/lib/rubyXL/objects/ooxml_object.rb +460 -0
- data/lib/rubyXL/objects/reference.rb +110 -0
- data/lib/rubyXL/objects/relationships.rb +213 -0
- data/lib/rubyXL/objects/root.rb +86 -0
- data/lib/rubyXL/objects/shared_strings.rb +70 -0
- data/lib/rubyXL/objects/sheet_common.rb +51 -0
- data/lib/rubyXL/objects/sheet_data.rb +188 -0
- data/lib/rubyXL/objects/simple_types.rb +232 -0
- data/lib/rubyXL/objects/storage.rb +182 -0
- data/lib/rubyXL/objects/stylesheet.rb +232 -0
- data/lib/rubyXL/objects/text.rb +94 -0
- data/lib/rubyXL/objects/theme.rb +1716 -0
- data/lib/rubyXL/objects/workbook.rb +464 -0
- data/lib/rubyXL/objects/worksheet.rb +748 -0
- data/lib/rubyXL/parser.rb +29 -0
- data/lib/rubyXL/worksheet.rb +105 -0
- data/rdoc/README_rdoc.html +475 -0
- data/rdoc/RubyXL.html +598 -0
- data/rdoc/RubyXL/AExtension.html +223 -0
- data/rdoc/RubyXL/AExtensionStorageArea.html +103 -0
- data/rdoc/RubyXL/ActiveX.html +182 -0
- data/rdoc/RubyXL/ActiveXBinary.html +117 -0
- data/rdoc/RubyXL/AdjustHandleList.html +106 -0
- data/rdoc/RubyXL/Alignment.html +106 -0
- data/rdoc/RubyXL/AlternateContent.html +103 -0
- data/rdoc/RubyXL/Authors.html +106 -0
- data/rdoc/RubyXL/AutoFilter.html +106 -0
- data/rdoc/RubyXL/AutoFilterColumn.html +106 -0
- data/rdoc/RubyXL/BinaryImageFile.html +122 -0
- data/rdoc/RubyXL/BodyProperties.html +106 -0
- data/rdoc/RubyXL/BooleanNode.html +103 -0
- data/rdoc/RubyXL/BooleanValue.html +103 -0
- data/rdoc/RubyXL/Border.html +275 -0
- data/rdoc/RubyXL/BorderEdge.html +189 -0
- data/rdoc/RubyXL/Borders.html +157 -0
- data/rdoc/RubyXL/Break.html +106 -0
- data/rdoc/RubyXL/BreakList.html +106 -0
- data/rdoc/RubyXL/CT_AdjPoint2D.html +106 -0
- data/rdoc/RubyXL/CT_AlphaBiLevelEffect.html +106 -0
- data/rdoc/RubyXL/CT_AlphaModulateEffect.html +106 -0
- data/rdoc/RubyXL/CT_AlphaModulateFixedEffect.html +106 -0
- data/rdoc/RubyXL/CT_AlphaOutsetEffect.html +106 -0
- data/rdoc/RubyXL/CT_AlphaReplaceEffect.html +106 -0
- data/rdoc/RubyXL/CT_Backdrop.html +106 -0
- data/rdoc/RubyXL/CT_Bevel.html +106 -0
- data/rdoc/RubyXL/CT_BiLevelEffect.html +106 -0
- data/rdoc/RubyXL/CT_BlendEffect.html +106 -0
- data/rdoc/RubyXL/CT_Blip.html +106 -0
- data/rdoc/RubyXL/CT_BlipFillProperties.html +106 -0
- data/rdoc/RubyXL/CT_BlurEffect.html +106 -0
- data/rdoc/RubyXL/CT_Camera.html +106 -0
- data/rdoc/RubyXL/CT_Color.html +106 -0
- data/rdoc/RubyXL/CT_ColorChangeEffect.html +106 -0
- data/rdoc/RubyXL/CT_ColorMapping.html +106 -0
- data/rdoc/RubyXL/CT_ColorScheme.html +106 -0
- data/rdoc/RubyXL/CT_ColorSchemeAndMapping.html +106 -0
- data/rdoc/RubyXL/CT_ConnectionSite.html +106 -0
- data/rdoc/RubyXL/CT_ConnectionSiteList.html +106 -0
- data/rdoc/RubyXL/CT_DashStop.html +106 -0
- data/rdoc/RubyXL/CT_DashStopList.html +106 -0
- data/rdoc/RubyXL/CT_DefaultShapeDefinition.html +106 -0
- data/rdoc/RubyXL/CT_DuotoneEffect.html +106 -0
- data/rdoc/RubyXL/CT_EffectContainer.html +106 -0
- data/rdoc/RubyXL/CT_EffectList.html +106 -0
- data/rdoc/RubyXL/CT_EffectReference.html +106 -0
- data/rdoc/RubyXL/CT_EffectStyleItem.html +106 -0
- data/rdoc/RubyXL/CT_EffectStyleList.html +106 -0
- data/rdoc/RubyXL/CT_EmbeddedWAVAudioFile.html +106 -0
- data/rdoc/RubyXL/CT_FillEffect.html +106 -0
- data/rdoc/RubyXL/CT_FillOverlayEffect.html +106 -0
- data/rdoc/RubyXL/CT_FillStyleList.html +106 -0
- data/rdoc/RubyXL/CT_FlatText.html +106 -0
- data/rdoc/RubyXL/CT_FontCollection.html +106 -0
- data/rdoc/RubyXL/CT_FontReference.html +106 -0
- data/rdoc/RubyXL/CT_GeomGuideList.html +106 -0
- data/rdoc/RubyXL/CT_GlowEffect.html +106 -0
- data/rdoc/RubyXL/CT_GradientFillProperties.html +106 -0
- data/rdoc/RubyXL/CT_GradientStop.html +106 -0
- data/rdoc/RubyXL/CT_GradientStopList.html +106 -0
- data/rdoc/RubyXL/CT_HSLEffect.html +106 -0
- data/rdoc/RubyXL/CT_HslColor.html +106 -0
- data/rdoc/RubyXL/CT_Hyperlink.html +106 -0
- data/rdoc/RubyXL/CT_InnerShadowEffect.html +106 -0
- data/rdoc/RubyXL/CT_LightRig.html +106 -0
- data/rdoc/RubyXL/CT_LineEndProperties.html +106 -0
- data/rdoc/RubyXL/CT_LineJoinMiterProperties.html +106 -0
- data/rdoc/RubyXL/CT_LineProperties.html +106 -0
- data/rdoc/RubyXL/CT_LineStyleList.html +106 -0
- data/rdoc/RubyXL/CT_LinearShadeProperties.html +106 -0
- data/rdoc/RubyXL/CT_LuminanceEffect.html +106 -0
- data/rdoc/RubyXL/CT_ObjectStyleDefaults.html +106 -0
- data/rdoc/RubyXL/CT_OuterShadowEffect.html +106 -0
- data/rdoc/RubyXL/CT_Path2D.html +106 -0
- data/rdoc/RubyXL/CT_Path2DArcTo.html +106 -0
- data/rdoc/RubyXL/CT_Path2DCubicBezierTo.html +106 -0
- data/rdoc/RubyXL/CT_Path2DList.html +106 -0
- data/rdoc/RubyXL/CT_Path2DQuadBezierTo.html +106 -0
- data/rdoc/RubyXL/CT_Path2DTo.html +106 -0
- data/rdoc/RubyXL/CT_PathShadeProperties.html +106 -0
- data/rdoc/RubyXL/CT_PatternFillProperties.html +106 -0
- data/rdoc/RubyXL/CT_Point3D.html +106 -0
- data/rdoc/RubyXL/CT_PolarAdjustHandle.html +106 -0
- data/rdoc/RubyXL/CT_PresetColor.html +106 -0
- data/rdoc/RubyXL/CT_PresetLineDashProperties.html +106 -0
- data/rdoc/RubyXL/CT_PresetShadowEffect.html +106 -0
- data/rdoc/RubyXL/CT_PresetTextShape.html +106 -0
- data/rdoc/RubyXL/CT_ReflectionEffect.html +106 -0
- data/rdoc/RubyXL/CT_RelativeOffsetEffect.html +106 -0
- data/rdoc/RubyXL/CT_RelativeRect.html +106 -0
- data/rdoc/RubyXL/CT_SRgbColor.html +106 -0
- data/rdoc/RubyXL/CT_ScRgbColor.html +106 -0
- data/rdoc/RubyXL/CT_Scene3D.html +106 -0
- data/rdoc/RubyXL/CT_SchemeColor.html +106 -0
- data/rdoc/RubyXL/CT_Shape3D.html +106 -0
- data/rdoc/RubyXL/CT_ShapeStyle.html +106 -0
- data/rdoc/RubyXL/CT_SoftEdgesEffect.html +106 -0
- data/rdoc/RubyXL/CT_SphereCoords.html +106 -0
- data/rdoc/RubyXL/CT_StretchInfoProperties.html +106 -0
- data/rdoc/RubyXL/CT_StyleMatrix.html +106 -0
- data/rdoc/RubyXL/CT_StyleMatrixReference.html +106 -0
- data/rdoc/RubyXL/CT_SupplementalFont.html +106 -0
- data/rdoc/RubyXL/CT_SystemColor.html +106 -0
- data/rdoc/RubyXL/CT_TextAutonumberBullet.html +106 -0
- data/rdoc/RubyXL/CT_TextBlipBullet.html +106 -0
- data/rdoc/RubyXL/CT_TextCharBullet.html +106 -0
- data/rdoc/RubyXL/CT_TextCharacterProperties.html +106 -0
- data/rdoc/RubyXL/CT_TextFont.html +106 -0
- data/rdoc/RubyXL/CT_TextListStyle.html +106 -0
- data/rdoc/RubyXL/CT_TextNormalAutofit.html +106 -0
- data/rdoc/RubyXL/CT_TextParagraphProperties.html +106 -0
- data/rdoc/RubyXL/CT_TextSpacing.html +106 -0
- data/rdoc/RubyXL/CT_TextTabStop.html +106 -0
- data/rdoc/RubyXL/CT_TextTabStopList.html +106 -0
- data/rdoc/RubyXL/CT_TileInfoProperties.html +106 -0
- data/rdoc/RubyXL/CT_TintEffect.html +106 -0
- data/rdoc/RubyXL/CT_Transform2D.html +106 -0
- data/rdoc/RubyXL/CT_TransformEffect.html +106 -0
- data/rdoc/RubyXL/CT_Vector3D.html +106 -0
- data/rdoc/RubyXL/CT_XYAdjustHandle.html +106 -0
- data/rdoc/RubyXL/CalculationChain.html +176 -0
- data/rdoc/RubyXL/CalculationChainCell.html +106 -0
- data/rdoc/RubyXL/CalculationProperties.html +106 -0
- data/rdoc/RubyXL/Cell.html +558 -0
- data/rdoc/RubyXL/CellConvenienceMethods.html +1211 -0
- data/rdoc/RubyXL/CellExt.html +106 -0
- data/rdoc/RubyXL/CellSmartTag.html +106 -0
- data/rdoc/RubyXL/CellSmartTagProperty.html +106 -0
- data/rdoc/RubyXL/CellSmartTags.html +106 -0
- data/rdoc/RubyXL/CellStyle.html +106 -0
- data/rdoc/RubyXL/CellStyleXFs.html +157 -0
- data/rdoc/RubyXL/CellStyles.html +157 -0
- data/rdoc/RubyXL/CellValue.html +158 -0
- data/rdoc/RubyXL/CellWatch.html +106 -0
- data/rdoc/RubyXL/CellWatches.html +106 -0
- data/rdoc/RubyXL/CellXFs.html +161 -0
- data/rdoc/RubyXL/ChartColorsFile.html +122 -0
- data/rdoc/RubyXL/ChartFile.html +189 -0
- data/rdoc/RubyXL/ChartStyleFile.html +122 -0
- data/rdoc/RubyXL/ChartUserShapesFile.html +122 -0
- data/rdoc/RubyXL/Chartsheet.html +260 -0
- data/rdoc/RubyXL/ChartsheetPageSetup.html +106 -0
- data/rdoc/RubyXL/ChartsheetProperties.html +106 -0
- data/rdoc/RubyXL/ChartsheetProtection.html +106 -0
- data/rdoc/RubyXL/ChartsheetView.html +106 -0
- data/rdoc/RubyXL/ChartsheetViews.html +106 -0
- data/rdoc/RubyXL/Color.html +175 -0
- data/rdoc/RubyXL/ColorFilter.html +106 -0
- data/rdoc/RubyXL/ColorScale.html +106 -0
- data/rdoc/RubyXL/ColorSet.html +106 -0
- data/rdoc/RubyXL/Colors.html +106 -0
- data/rdoc/RubyXL/ColumnRange.html +245 -0
- data/rdoc/RubyXL/ColumnRanges.html +289 -0
- data/rdoc/RubyXL/Comment.html +106 -0
- data/rdoc/RubyXL/CommentList.html +106 -0
- data/rdoc/RubyXL/CommentsFile.html +197 -0
- data/rdoc/RubyXL/ConditionalFormatValue.html +106 -0
- data/rdoc/RubyXL/ConditionalFormatting.html +106 -0
- data/rdoc/RubyXL/ConditionalFormattingRule.html +106 -0
- data/rdoc/RubyXL/ContentTypeDefault.html +103 -0
- data/rdoc/RubyXL/ContentTypeOverride.html +103 -0
- data/rdoc/RubyXL/ContentTypes.html +248 -0
- data/rdoc/RubyXL/ControlPropertiesFile.html +117 -0
- data/rdoc/RubyXL/CorePropertiesFile.html +474 -0
- data/rdoc/RubyXL/CustomColor.html +106 -0
- data/rdoc/RubyXL/CustomColorList.html +106 -0
- data/rdoc/RubyXL/CustomFilter.html +106 -0
- data/rdoc/RubyXL/CustomFilters.html +106 -0
- data/rdoc/RubyXL/CustomGeometry.html +106 -0
- data/rdoc/RubyXL/CustomProperties.html +106 -0
- data/rdoc/RubyXL/CustomPropertiesFile.html +122 -0
- data/rdoc/RubyXL/CustomProperty.html +106 -0
- data/rdoc/RubyXL/CustomSheetView.html +106 -0
- data/rdoc/RubyXL/CustomSheetViews.html +106 -0
- data/rdoc/RubyXL/CustomWorkbookView.html +106 -0
- data/rdoc/RubyXL/CustomWorkbookViews.html +106 -0
- data/rdoc/RubyXL/CustomXMLFile.html +117 -0
- data/rdoc/RubyXL/DXF.html +106 -0
- data/rdoc/RubyXL/DXFs.html +106 -0
- data/rdoc/RubyXL/DataBar.html +106 -0
- data/rdoc/RubyXL/DataConsolidate.html +106 -0
- data/rdoc/RubyXL/DataConsolidationReference.html +106 -0
- data/rdoc/RubyXL/DataConsolidationReferences.html +106 -0
- data/rdoc/RubyXL/DataType.html +143 -0
- data/rdoc/RubyXL/DataValidation.html +106 -0
- data/rdoc/RubyXL/DataValidations.html +106 -0
- data/rdoc/RubyXL/DateGroupItem.html +106 -0
- data/rdoc/RubyXL/DefinedName.html +106 -0
- data/rdoc/RubyXL/DefinedNameExt.html +106 -0
- data/rdoc/RubyXL/DefinedNames.html +106 -0
- data/rdoc/RubyXL/DefinedNamesExt.html +106 -0
- data/rdoc/RubyXL/DocumentPropertiesFile.html +255 -0
- data/rdoc/RubyXL/DrawingFile.html +188 -0
- data/rdoc/RubyXL/DynamicFilter.html +106 -0
- data/rdoc/RubyXL/EmbeddedControl.html +106 -0
- data/rdoc/RubyXL/EmbeddedControls.html +106 -0
- data/rdoc/RubyXL/Extension.html +106 -0
- data/rdoc/RubyXL/ExtensionStorageArea.html +106 -0
- data/rdoc/RubyXL/Extents.html +106 -0
- data/rdoc/RubyXL/ExternalBook.html +106 -0
- data/rdoc/RubyXL/ExternalLinksFile.html +184 -0
- data/rdoc/RubyXL/ExternalReference.html +106 -0
- data/rdoc/RubyXL/ExternalReferences.html +106 -0
- data/rdoc/RubyXL/ExtraColorSchemeList.html +106 -0
- data/rdoc/RubyXL/FieldItem.html +106 -0
- data/rdoc/RubyXL/FileRecoveryProperties.html +106 -0
- data/rdoc/RubyXL/FileSharing.html +106 -0
- data/rdoc/RubyXL/FileVersion.html +106 -0
- data/rdoc/RubyXL/Fill.html +157 -0
- data/rdoc/RubyXL/Fills.html +157 -0
- data/rdoc/RubyXL/FilterContainer.html +106 -0
- data/rdoc/RubyXL/FloatNode.html +103 -0
- data/rdoc/RubyXL/FloatValue.html +103 -0
- data/rdoc/RubyXL/Font.html +184 -0
- data/rdoc/RubyXL/FontConvenienceMethods.html +603 -0
- data/rdoc/RubyXL/FontScheme.html +106 -0
- data/rdoc/RubyXL/Fonts.html +157 -0
- data/rdoc/RubyXL/Formula.html +106 -0
- data/rdoc/RubyXL/FunctionGroup.html +106 -0
- data/rdoc/RubyXL/FunctionGroups.html +106 -0
- data/rdoc/RubyXL/GenericStorageObject.html +298 -0
- data/rdoc/RubyXL/GradientFill.html +106 -0
- data/rdoc/RubyXL/HeaderFooterSettings.html +106 -0
- data/rdoc/RubyXL/Hyperlink.html +106 -0
- data/rdoc/RubyXL/HyperlinkRelFile.html +117 -0
- data/rdoc/RubyXL/Hyperlinks.html +106 -0
- data/rdoc/RubyXL/IconFilter.html +106 -0
- data/rdoc/RubyXL/IconSet.html +106 -0
- data/rdoc/RubyXL/IgnoredError.html +106 -0
- data/rdoc/RubyXL/IgnoredErrors.html +106 -0
- data/rdoc/RubyXL/IndexedColors.html +106 -0
- data/rdoc/RubyXL/InputCells.html +106 -0
- data/rdoc/RubyXL/IntegerNode.html +103 -0
- data/rdoc/RubyXL/IntegerValue.html +103 -0
- data/rdoc/RubyXL/LegacyCell.html +181 -0
- data/rdoc/RubyXL/LegacyWorksheet.html +355 -0
- data/rdoc/RubyXL/MRUColors.html +106 -0
- data/rdoc/RubyXL/MacrosFile.html +122 -0
- data/rdoc/RubyXL/MergedCell.html +106 -0
- data/rdoc/RubyXL/MergedCells.html +106 -0
- data/rdoc/RubyXL/NumFmt.html +106 -0
- data/rdoc/RubyXL/NumberFormat.html +158 -0
- data/rdoc/RubyXL/NumberFormats.html +172 -0
- data/rdoc/RubyXL/OLEObject.html +106 -0
- data/rdoc/RubyXL/OLEObjectFile.html +122 -0
- data/rdoc/RubyXL/OLEObjects.html +106 -0
- data/rdoc/RubyXL/OLESize.html +106 -0
- data/rdoc/RubyXL/OOXMLContainerObject.html +394 -0
- data/rdoc/RubyXL/OOXMLObject.html +118 -0
- data/rdoc/RubyXL/OOXMLObjectClassMethods.html +532 -0
- data/rdoc/RubyXL/OOXMLObjectInstanceMethods.html +564 -0
- data/rdoc/RubyXL/OOXMLRelationshipsFile.html +603 -0
- data/rdoc/RubyXL/OOXMLTopLevelObject.html +384 -0
- data/rdoc/RubyXL/Offset.html +106 -0
- data/rdoc/RubyXL/OutlineProperties.html +106 -0
- data/rdoc/RubyXL/PageMargins.html +106 -0
- data/rdoc/RubyXL/PageSetup.html +106 -0
- data/rdoc/RubyXL/PageSetupProperties.html +106 -0
- data/rdoc/RubyXL/Pane.html +106 -0
- data/rdoc/RubyXL/Parser.html +204 -0
- data/rdoc/RubyXL/PatternFill.html +106 -0
- data/rdoc/RubyXL/PhoneticProperties.html +106 -0
- data/rdoc/RubyXL/PhoneticRun.html +106 -0
- data/rdoc/RubyXL/PivotArea.html +106 -0
- data/rdoc/RubyXL/PivotCache.html +106 -0
- data/rdoc/RubyXL/PivotCacheDefinitionFile.html +133 -0
- data/rdoc/RubyXL/PivotCacheRecordsFile.html +122 -0
- data/rdoc/RubyXL/PivotCaches.html +106 -0
- data/rdoc/RubyXL/PivotReference.html +106 -0
- data/rdoc/RubyXL/PivotReferences.html +106 -0
- data/rdoc/RubyXL/PivotTableFile.html +133 -0
- data/rdoc/RubyXL/PivotTableSelection.html +106 -0
- data/rdoc/RubyXL/PresetGeometry.html +106 -0
- data/rdoc/RubyXL/PrintOptions.html +106 -0
- data/rdoc/RubyXL/PrinterSettingsFile.html +122 -0
- data/rdoc/RubyXL/ProtectedRange.html +106 -0
- data/rdoc/RubyXL/ProtectedRanges.html +106 -0
- data/rdoc/RubyXL/Protection.html +106 -0
- data/rdoc/RubyXL/RID.html +103 -0
- data/rdoc/RubyXL/RawOOXML.html +223 -0
- data/rdoc/RubyXL/Reference.html +640 -0
- data/rdoc/RubyXL/Relationship.html +103 -0
- data/rdoc/RubyXL/RelationshipSupport.html +419 -0
- data/rdoc/RubyXL/RelationshipSupport/ClassMehods.html +148 -0
- data/rdoc/RubyXL/RichText.html +159 -0
- data/rdoc/RubyXL/RichTextRun.html +157 -0
- data/rdoc/RubyXL/Row.html +439 -0
- data/rdoc/RubyXL/RowExt.html +106 -0
- data/rdoc/RubyXL/RunProperties.html +106 -0
- data/rdoc/RubyXL/Scenario.html +106 -0
- data/rdoc/RubyXL/Scenarios.html +106 -0
- data/rdoc/RubyXL/Selection.html +165 -0
- data/rdoc/RubyXL/ShapeGuide.html +106 -0
- data/rdoc/RubyXL/ShapeTextRectangle.html +106 -0
- data/rdoc/RubyXL/SharedStringsTable.html +424 -0
- data/rdoc/RubyXL/Sheet.html +106 -0
- data/rdoc/RubyXL/SheetCalculationProperties.html +106 -0
- data/rdoc/RubyXL/SheetData.html +192 -0
- data/rdoc/RubyXL/SheetDataExt.html +106 -0
- data/rdoc/RubyXL/SheetDataSet.html +106 -0
- data/rdoc/RubyXL/SheetName.html +106 -0
- data/rdoc/RubyXL/SheetNames.html +106 -0
- data/rdoc/RubyXL/Sheets.html +106 -0
- data/rdoc/RubyXL/SlicerCacheFile.html +122 -0
- data/rdoc/RubyXL/SlicerFile.html +122 -0
- data/rdoc/RubyXL/SmartTagProperties.html +106 -0
- data/rdoc/RubyXL/SmartTagType.html +106 -0
- data/rdoc/RubyXL/SmartTagTypes.html +106 -0
- data/rdoc/RubyXL/SmartTags.html +106 -0
- data/rdoc/RubyXL/SortCondition.html +106 -0
- data/rdoc/RubyXL/SortState.html +106 -0
- data/rdoc/RubyXL/Sqref.html +197 -0
- data/rdoc/RubyXL/Stop.html +106 -0
- data/rdoc/RubyXL/StringNode.html +103 -0
- data/rdoc/RubyXL/StringNodeW3C.html +197 -0
- data/rdoc/RubyXL/StringValue.html +103 -0
- data/rdoc/RubyXL/Stylesheet.html +354 -0
- data/rdoc/RubyXL/TableFile.html +122 -0
- data/rdoc/RubyXL/TableParts.html +103 -0
- data/rdoc/RubyXL/TableStyle.html +106 -0
- data/rdoc/RubyXL/TableStyles.html +106 -0
- data/rdoc/RubyXL/Text.html +216 -0
- data/rdoc/RubyXL/Theme.html +535 -0
- data/rdoc/RubyXL/ThemeElements.html +106 -0
- data/rdoc/RubyXL/ThumbnailFile.html +122 -0
- data/rdoc/RubyXL/Top10.html +106 -0
- data/rdoc/RubyXL/VMLDrawingFile.html +134 -0
- data/rdoc/RubyXL/Variant.html +106 -0
- data/rdoc/RubyXL/Vector.html +161 -0
- data/rdoc/RubyXL/VectorValue.html +103 -0
- data/rdoc/RubyXL/VisualProperties.html +106 -0
- data/rdoc/RubyXL/WebPublishObject.html +106 -0
- data/rdoc/RubyXL/WebPublishObjects.html +106 -0
- data/rdoc/RubyXL/WebPublishingItem.html +106 -0
- data/rdoc/RubyXL/WebPublishingItems.html +106 -0
- data/rdoc/RubyXL/WebPublishingProperties.html +106 -0
- data/rdoc/RubyXL/Workbook.html +633 -0
- data/rdoc/RubyXL/WorkbookConvenienceMethods.html +1321 -0
- data/rdoc/RubyXL/WorkbookProperties.html +106 -0
- data/rdoc/RubyXL/WorkbookProtection.html +106 -0
- data/rdoc/RubyXL/WorkbookRoot.html +402 -0
- data/rdoc/RubyXL/WorkbookView.html +106 -0
- data/rdoc/RubyXL/WorkbookViews.html +106 -0
- data/rdoc/RubyXL/Worksheet.html +433 -0
- data/rdoc/RubyXL/WorksheetConvenienceMethods.html +2861 -0
- data/rdoc/RubyXL/WorksheetDimensions.html +106 -0
- data/rdoc/RubyXL/WorksheetFormatProperties.html +103 -0
- data/rdoc/RubyXL/WorksheetProperties.html +106 -0
- data/rdoc/RubyXL/WorksheetProtection.html +106 -0
- data/rdoc/RubyXL/WorksheetView.html +106 -0
- data/rdoc/RubyXL/WorksheetViews.html +106 -0
- data/rdoc/RubyXL/XF.html +106 -0
- data/rdoc/created.rid +38 -0
- data/rdoc/css/fonts.css +167 -0
- data/rdoc/css/rdoc.css +590 -0
- data/rdoc/fonts/Lato-Light.ttf +0 -0
- data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
- data/rdoc/fonts/Lato-Regular.ttf +0 -0
- data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
- data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +796 -0
- data/rdoc/js/darkfish.js +161 -0
- data/rdoc/js/jquery.js +4 -0
- data/rdoc/js/navigation.js +142 -0
- data/rdoc/js/navigation.js.gz +0 -0
- data/rdoc/js/search.js +109 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/search_index.js.gz +0 -0
- data/rdoc/js/searcher.js +229 -0
- data/rdoc/js/searcher.js.gz +0 -0
- data/rdoc/table_of_contents.html +2758 -0
- data/rubyXL.gemspec +516 -0
- data/spec/lib/cell_spec.rb +515 -0
- data/spec/lib/color_spec.rb +13 -0
- data/spec/lib/parser_spec.rb +118 -0
- data/spec/lib/reference_spec.rb +28 -0
- data/spec/lib/stylesheet_spec.rb +28 -0
- data/spec/lib/text_spec.rb +29 -0
- data/spec/lib/workbook_spec.rb +174 -0
- data/spec/lib/worksheet_spec.rb +1363 -0
- data/spec/spec_helper.rb +11 -0
- data/test/input/.gitkeep +0 -0
- data/test/output/.gitkeep +0 -0
- data/test/test_parse_write.rb +15 -0
- data/tmp/.gitignore +1 -0
- metadata +615 -0
@@ -0,0 +1,1122 @@
|
|
1
|
+
module RubyXL
|
2
|
+
|
3
|
+
module WorkbookConvenienceMethods
|
4
|
+
SHEET_NAME_TEMPLATE = 'Sheet%d'
|
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
|