Sha256: 1ee8381f9d40d36b5517883b4f6499865bfe136cf10df4fcb89f49b90b07cdca
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
require_relative 'worksheet' module Workbook def self.rubyxl_to_hash(rubyxl_workbook) hash_workbook = {} rubyxl_workbook.each do |rubyxl_worksheet| hash_workbook[rubyxl_worksheet.sheet_name] = Worksheet.rubyxl_to_hash(rubyxl_worksheet) end hash_workbook end def self.hash_workbook_to_rubyxl_workbook(hash_workbook) validate_hash_workbook(hash_workbook) rubyxl_workbook = RubyXL::Workbook.new first_worksheet = true hash_workbook.each do |hash_key, hash_value| if first_worksheet rubyxl_workbook.worksheets[0].sheet_name = hash_key first_worksheet = false else rubyxl_workbook.add_worksheet(hash_key) end Worksheet.hash_worksheet_to_rubyxl_worksheet(hash_value, rubyxl_workbook[hash_key]) end rubyxl_workbook end def self.hash_workbook_to_hash_tables(hash_workbook) hash_workbook.keys.each_with_object({}) do |key, hash_tables| hash_tables[key] = Worksheet.hash_worksheet_to_hash_table(hash_workbook[key]) end end def self.validate_hash_workbook(hash_workbook) raise('workbook must be a Hash') unless hash_workbook.is_a?(Hash) hash_workbook.each do |hash_worksheet_name, hash_worksheet| Worksheet.validate_hash_worksheet(hash_worksheet_name, hash_worksheet) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rxl-0.2.1 | lib/workbook.rb |