Class: OoxmlParser::XlsxCell
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::XlsxCell
- Defined in:
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb
Overview
Single Cell of XLSX
Instance Attribute Summary collapse
-
#character ⇒ Object
Returns the value of attribute character.
-
#formula ⇒ Object
Returns the value of attribute formula.
-
#raw_text ⇒ String
Text without applying any style modificators, like quote_prefix.
-
#reference ⇒ String
readonly
An A-1 style reference to a cell.
-
#style_index ⇒ Integer
readonly
Index of style.
-
#type ⇒ String
readonly
Type of string.
-
#value ⇒ String
readonly
Value of cell.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#coordinates ⇒ Coordinates
Coordinates of cell.
-
#initialize(parent: nil) ⇒ XlsxCell
constructor
A new instance of XlsxCell.
-
#parse(node) ⇒ XlsxCell
Parse XlsxCell object.
-
#style ⇒ Xf
Style of cell.
-
#text ⇒ String
Text with modifiers.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ XlsxCell
Returns a new instance of XlsxCell.
20 21 22 23 24 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 20 def initialize(parent: nil) @style_index = 0 # default style is zero @raw_text = '' super end |
Instance Attribute Details
#character ⇒ Object
Returns the value of attribute character.
7 8 9 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 7 def character @character end |
#formula ⇒ Object
Returns the value of attribute formula.
7 8 9 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 7 def formula @formula end |
#raw_text ⇒ String
Returns text without applying any style modificators, like quote_prefix.
10 11 12 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 10 def raw_text @raw_text end |
#reference ⇒ String (readonly)
Returns An A-1 style reference to a cell.
16 17 18 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 16 def reference @reference end |
#style_index ⇒ Integer (readonly)
Returns index of style.
12 13 14 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 12 def style_index @style_index end |
#type ⇒ String (readonly)
Returns type of string.
18 19 20 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 18 def type @type end |
#value ⇒ String (readonly)
Returns value of cell.
14 15 16 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 14 def value @value end |
Instance Method Details
#coordinates ⇒ Coordinates
Returns coordinates of cell.
68 69 70 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 68 def coordinates @coordinates ||= Coordinates.new.parse_string(@reference) end |
#parse(node) ⇒ XlsxCell
Parse XlsxCell object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 29 def parse(node) node.attributes.each do |key, value| case key when 's' @style_index = value.value.to_i when 't' @type = value.value.to_s when 'r' @reference = value.value.to_s end end node.xpath('*').each do |node_child| case node_child.name when 'f' @formula = Formula.new(parent: self).parse(node_child) when 'v' @value = TextValue.new(parent: self).parse(node_child) end end parse_text_data self end |
#style ⇒ Xf
Returns style of cell.
53 54 55 56 57 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 53 def style return nil unless @style_index root_object.style_sheet.cell_xfs.xf_array[@style_index] end |
#text ⇒ String
Returns text with modifiers.
60 61 62 63 64 65 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb', line 60 def text return '' unless @raw_text return @raw_text.dup.insert(0, "'") if style.quote_prefix @raw_text end |