class OoxmlParser::XlsxCell
Single Cell of XLSX
Attributes
character[RW]
formula[RW]
raw_text[RW]
@return [String] text without applying any style modificators, like quote_prefix
style_index[R]
@return [Integer] index of style
type[R]
@return [String] type of string
value[R]
@return [String] value of cell
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/worksheet/xlsx_row/xlsx_cell.rb, line 18 def initialize(parent: nil) @style_index = 0 # default style is zero @raw_text = '' super end
Public Instance Methods
parse(node)
click to toggle source
Parse XlsxCell
object @param node [Nokogiri::XML:Element] node to parse @return [XlsxCell] result of parsing
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb, line 27 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 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()
click to toggle source
@return [Xf] style of cell
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb, line 49 def style return nil unless @style_index root_object.style_sheet.cell_xfs.xf_array[@style_index] end
text()
click to toggle source
@return [String] text with modifiers
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb, line 56 def text return '' unless @raw_text return @raw_text.dup.insert(0, "'") if style.quote_prefix @raw_text end
Private Instance Methods
parse_text_data()
click to toggle source
@return [Nothing] parse text data
# File lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/worksheet/xlsx_row/xlsx_cell.rb, line 66 def parse_text_data if @type && @value type == 's' ? get_shared_string(value.value) : @raw_text = value.value elsif @value @raw_text = value.value if @value end end