Class: ChupaText::Decomposers::OfficeOpenXMLWorkbook::SheetListener

Inherits:
SAXListener
  • Object
show all
Defined in:
lib/chupa-text/decomposers/office-open-xml-workbook.rb

Constant Summary collapse

URI =
"http://schemas.openxmlformats.org/spreadsheetml/2006/main"

Instance Method Summary collapse

Constructor Details

#initialize(sheet) ⇒ SheetListener

Returns a new instance of SheetListener.



119
120
121
122
123
# File 'lib/chupa-text/decomposers/office-open-xml-workbook.rb', line 119

def initialize(sheet)
  @sheet = sheet
  @cell_type = nil
  @in_v = false
end

Instance Method Details

#cdata(content) ⇒ Object



152
153
154
# File 'lib/chupa-text/decomposers/office-open-xml-workbook.rb', line 152

def cdata(content)
  add_column(content)
end

#characters(text) ⇒ Object



148
149
150
# File 'lib/chupa-text/decomposers/office-open-xml-workbook.rb', line 148

def characters(text)
  add_column(text)
end

#end_element(uri, local_name, qname) ⇒ Object



138
139
140
141
142
143
144
145
146
# File 'lib/chupa-text/decomposers/office-open-xml-workbook.rb', line 138

def end_element(uri, local_name, qname)
  return unless uri == URI
  case local_name
  when "c"
    @cell_type = nil
  when "v"
    @in_v = false
  end
end

#start_element(uri, local_name, qname, attributes) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/chupa-text/decomposers/office-open-xml-workbook.rb', line 125

def start_element(uri, local_name, qname, attributes)
  return unless uri == URI
  case local_name
  when "row"
    @sheet << []
  when "c"
    @cell_type = parse_cell_type(attributes["t"])
  # when "is" # TODO
  when "v"
    @in_v = true
  end
end