class OoxmlParser::XlsxCell
Single Cell of XLSX
Attributes
@return [String] text without applying any style modificators, like quote_prefix
@return [String] An A-1 style reference to a cell.
@return [Integer] index of style
@return [String] type of string
@return [String] value of cell
Public Class Methods
Source
# 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
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
Public Instance Methods
Source
# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb, line 68 def coordinates @coordinates ||= Coordinates.new.parse_string(@reference) end
@return [Coordinates] coordinates of cell
Source
# 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
Parse XlsxCell
object @param node [Nokogiri::XML:Element] node to parse @return [XlsxCell] result of parsing
Source
# 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
@return [Xf] style of cell
Source
# 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
@return [String] text with modifiers
Private Instance Methods
Source
# File lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_row/xlsx_cell.rb, line 75 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
@return [Nothing] parse text data