Class: RubyXL::Parser
- Inherits:
-
Object
- Object
- RubyXL::Parser
- Defined in:
- lib/rubyXL/parser.rb
Class Method Summary collapse
-
.parse(src_file_path) ⇒ Object
Parse
.xslx
file by reading it from local disk. -
.parse_buffer(buffer) ⇒ Object
Parse
.xslx
file contained in a stream (useful for receiving over HTTP).
Class Method Details
.parse(src_file_path) ⇒ Object
Parse .xslx
file by reading it from local disk.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/rubyXL/parser.rb', line 4 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_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 |