class OoxmlParser::Xf
Class for parsing `xf` object
Constants
- ALL_FORMAT_VALUE
- Array<String,nil>
-
list of predefined format values
Attributes
alignment[R]
apply_alignment[R]
@return [True, False] is alignment applied
apply_border[R]
@return [True, False] is border applied
apply_fill[R]
@return [True, False] is fill applied
apply_font[R]
@return [True, False] is font applied
apply_number_format[R]
@return [True, False] is number format applied
border_id[R]
@return [Integer] id of border
fill_id[R]
@return [Integer] id of fill
font_id[R]
@return [Integer] id of font
number_format_id[R]
@return [Integer] id of number format
quote_prefix[R]
@return [True, False] check if style should add QuotePrefix (' symbol) to start of the string
Public Class Methods
new(parent: nil)
click to toggle source
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb, line 80 def initialize(parent: nil) @numerical_format = 'General' @alignment = XlsxAlignment.new super end
Public Instance Methods
borders()
click to toggle source
@return [XlsxBorder] border of object
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb, line 129 def borders root_object.style_sheet.borders.borders_array[@border_id] if @apply_border end
fill_color()
click to toggle source
@return [Fill] fill color of object
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb, line 134 def fill_color root_object.style_sheet.fills[@fill_id] if @apply_fill end
font()
click to toggle source
@return [Font] font of object
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb, line 124 def font root_object.style_sheet.fonts[@font_id] end
numerical_format()
click to toggle source
@return [String] numerical format of object
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb, line 139 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
parse(node)
click to toggle source
Parse Xf
object @param node [Nokogiri::XML:Element] node to parse @return [Xf] result of parsing
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/cell_xfs/xf.rb, line 89 def parse(node) node.attributes.each do |key, value| case key when 'applyFont' @apply_font = attribute_enabled?(value) when 'applyBorder' @apply_border = attribute_enabled?(value) when 'applyFill' @apply_fill = attribute_enabled?(value) when 'applyNumberFormat' @apply_number_format = attribute_enabled?(value) when 'applyAlignment' @apply_alignment = attribute_enabled?(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 end end self end