class OoxmlParser::XlsxColumnProperties

Properties of XLSX column

Attributes

best_fit[RW]

@return [True, False] Flag indicating if the specified column(s) is set to 'best fit'

custom_width[RW]

@return [True, False] is width custom

from[RW]
hidden[R]

@return [True, False] Flag indicating if the specified column(s) is hidden

style[RW]
to[RW]
width[RW]

Public Class Methods

parse_list(columns_width_node, parent: nil) click to toggle source

Parse list of XlsxColumnProperties @param columns_width_node [Nokogiri::XML:Element] node to parse @param parent [OOXMLDocumentObject] parent of result objects @return [Array<XlsxColumnProperties>] list of XlsxColumnProperties

# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb, line 45
def self.parse_list(columns_width_node, parent: nil)
  columns = []
  columns_width_node.xpath('xmlns:col').each do |col_node|
    col = XlsxColumnProperties.new(parent: parent).parse(col_node)
    columns << col
  end
  columns
end

Public Instance Methods

parse(node) click to toggle source

Parse XlsxColumnProperties object @param node [Nokogiri::XML:Element] node to parse @return [XlsxColumnProperties] result of parsing

# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb, line 19
def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'min'
      @from = value.value.to_i
    when 'max'
      @to = value.value.to_i
    when 'style'
      @style = root_object.style_sheet.cell_xfs.xf_array[value.value.to_i]
    when 'width'
      @width = value.value.to_f - 0.7109375
    when 'customWidth'
      @custom_width = option_enabled?(node, 'customWidth')
    when 'bestFit'
      @best_fit = attribute_enabled?(value)
    when 'hidden'
      @hidden = attribute_enabled?(value)
    end
  end
  self
end