Method: RubyXL::Parser.parse_buffer

Defined in:
lib/rubyXL/parser.rb

.parse_buffer(buffer) ⇒ Object

Parse .xslx file contained in a stream (useful for receiving over HTTP).



17
18
19
20
21
22
23
24
25
# File 'lib/rubyXL/parser.rb', line 17

def self.parse_buffer(buffer)
  root = nil # Zip::File.open_buffer somehow fails to return the value from the block :(
  begin
    ::Zip::File.open_buffer(buffer) { |zip_file| root = RubyXL::WorkbookRoot.parse_zip_file(zip_file) }
    root.workbook
  rescue ::Zip::Error => e
    raise e, "XLSX file format error: #{e}", e.backtrace
  end
end