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
124
# File 'lib/chupa-text/decomposers/office-open-xml-workbook.rb', line 119

def initialize(sheet)
  @sheet = sheet
  @cell_type = nil
  @in_is = false # inline string
  @in_v = false # value
end

Instance Method Details

#cdata(content) ⇒ Object



156
157
158
# File 'lib/chupa-text/decomposers/office-open-xml-workbook.rb', line 156

def cdata(content)
  add_column(content)
end

#characters(text) ⇒ Object



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

def characters(text)
  add_column(text)
end

#end_element(uri, local_name, qname) ⇒ Object



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

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

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



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

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"
    @in_is = true
  when "v"
    @in_v = true
  end
end