class OoxmlParser::Xf
Class for parsing ‘xf` object
Constants
- ALL_FORMAT_VALUE
-
- Array<String,nil>
-
list of predefined format values
Attributes
@return [True, False] is alignment applied
@return [True, False] is border applied
@return [True, False] is fill applied
@return [True, False] is font applied
@return [True, False] is number format applied
@return [Integer] id of border
@return [Integer] id of fill
@return [Integer] id of font
@return [Integer] id of number format
@return [Protection] Settings of cell protection
@return [True, False] check if style should add QuotePrefix (‘ symbol) to start of the string
Public Class Methods
Source
# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/xf.rb, line 83 def initialize(parent: nil) @numerical_format = 'General' @alignment = XlsxAlignment.new super end
OoxmlParser::OOXMLDocumentObject::new
Public Instance Methods
Source
# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/xf.rb, line 134 def borders root_object.style_sheet.borders.borders_array[@border_id] if @apply_border end
@return [XlsxBorder] border of object
Source
# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/xf.rb, line 139 def fill_color root_object.style_sheet.fills[@fill_id] if @apply_fill end
@return [Fill] fill color of object
Source
# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/xf.rb, line 129 def font root_object.style_sheet.fonts[@font_id] end
@return [Font] font of object
Source
# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/xf.rb, line 144 def numerical_format return @numerical_format unless @apply_number_format format = root_object.style_sheet.number_formats.format_by_id(@number_format_id) if format format.format_code else ALL_FORMAT_VALUE[@number_format_id] end end
@return [String] numerical format of object
Source
# File lib/ooxml_parser/xlsx_parser/workbook/style_sheet/cell_xfs/xf.rb, line 92 def parse(node) node.attributes.each do |key, value| case key when 'applyFont' @apply_font = boolean_attribute_value(value) when 'applyBorder' @apply_border = boolean_attribute_value(value) when 'applyFill' @apply_fill = boolean_attribute_value(value) when 'applyNumberFormat' @apply_number_format = boolean_attribute_value(value) when 'applyAlignment' @apply_alignment = boolean_attribute_value(value) when 'fontId' @font_id = value.value.to_i when 'borderId' @border_id = value.value.to_i when 'fillId' @fill_id = value.value.to_i when 'numFmtId' @number_format_id = value.value.to_i when 'quotePrefix' @quote_prefix = attribute_enabled?(value) end end node.xpath('*').each do |node_child| case node_child.name when 'alignment' @alignment.parse(node_child) if @apply_alignment when 'protection' @protection = Protection.new(parent: self).parse(node_child) end end self end
Parse Xf
object @param node [Nokogiri::XML:Element] node to parse @return [Xf] result of parsing