Class: OoxmlParser::XlsxColumnProperties

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb

Overview

Properties of XLSX column

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, #initialize, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#best_fitTrue, False

specified column(s) is set to ‘best fit’

Returns:

  • (True, False)

    Flag indicating if the



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 9

def best_fit
  @best_fit
end

#custom_widthTrue, False

Returns is width custom.

Returns:

  • (True, False)

    is width custom



6
7
8
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 6

def custom_width
  @custom_width
end

#fromObject

Returns the value of attribute from.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 4

def from
  @from
end

#styleObject

Returns the value of attribute style.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 4

def style
  @style
end

#toObject

Returns the value of attribute to.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 4

def to
  @to
end

#widthObject

Returns the value of attribute width.



4
5
6
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 4

def width
  @width
end

Class Method Details

.parse_list(columns_width_node, parent: nil) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 34

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

Instance Method Details

#parse(node) ⇒ XlsxColumnProperties

Parse XlsxColumnProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_column_properties.rb', line 14

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 = CellStyle.new(parent: self).parse(value.value)
    when 'width'
      @width = value.value.to_f - 0.7109375
    when 'customWidth'
      @custom_width = option_enabled?(node, 'customWidth')
    when 'bestFit'
      @best_fit = attribute_enabled?(value)
    end
  end
  self
end