Sha256: 154be2e1734eceb1311836d57cfde567c209d0868e87df5dbf9718400accc865

Contents?: true

Size: 928 Bytes

Versions: 43

Compression:

Stored size: 928 Bytes

Contents

module RubyXL
  class Parser

    # Parse <tt>.xslx</tt> file by reading it from local disk.
    def self.parse(src_file_path)
      begin
        ::Zip::File.open(src_file_path) { |zip_file|
          root = RubyXL::WorkbookRoot.parse_zip_file(zip_file)
          root.source_file_path = src_file_path
          root.workbook
        }
      rescue ::Zip::Error => e
        raise e, "XLSX file format error: #{e}", e.backtrace
      end
    end

    # Parse <tt>.xslx</tt> file contained in a stream (useful for receiving over HTTP).
    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

  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
rubyXL-3.4.0 lib/rubyXL/parser.rb
rubyXL-3.3.33 lib/rubyXL/parser.rb
rubyXL-3.3.31 lib/rubyXL/parser.rb
rubyXL-3.3.30 lib/rubyXL/parser.rb
rubyXL-3.3.29 lib/rubyXL/parser.rb
rubyXL-ptr-3.3.27 lib/rubyXL/parser.rb
rubyXL-3.3.28 lib/rubyXL/parser.rb
rubyXL-3.3.27 lib/rubyXL/parser.rb
rubyXL-3.3.26 lib/rubyXL/parser.rb
rubyXL-3.3.25 lib/rubyXL/parser.rb
rubyXL-3.3.24 lib/rubyXL/parser.rb
rubyXL-3.3.23 lib/rubyXL/parser.rb
rubyXL-3.3.22 lib/rubyXL/parser.rb
rubyXL-3.3.21 lib/rubyXL/parser.rb
rubyXL-3.3.20 lib/rubyXL/parser.rb
rubyXL-3.3.19 lib/rubyXL/parser.rb
rubyXL-3.3.18 lib/rubyXL/parser.rb
rubyXL-3.3.17 lib/rubyXL/parser.rb
rubyXL-3.3.16 lib/rubyXL/parser.rb
rubyXL-3.3.15 lib/rubyXL/parser.rb