class MergeExcel::SpreadsheetWriter

Public Class Methods

create(filepath) { |wb| ... } click to toggle source
# File lib/merge_excel/spreadsheet_writer.rb, line 5
def self.create(filepath)
  extname = detect_format(filepath)
  wb = case extname
  when :xls
    Spreadsheet::Workbook.new
  when :xlsx
    RubyXL::Workbook.new
  else
    raise "Invalid format"
  end

  yield(wb)
  wb.write filepath
end