Method: RubyXL::Workbook#save

Defined in:
lib/rubyXL/objects/workbook.rb

#save(dst_file_path = nil) ⇒ Object Also known as: write

Save the resulting XLSX file to the specified location

[View source]

399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/rubyXL/objects/workbook.rb', line 399

def save(dst_file_path = nil)
  dst_file_path ||= root.source_file_path

  extension = File.extname(dst_file_path)
  unless %w{.xlsx .xlsm .xltx .xltm}.include?(extension.downcase)
    raise "Unsupported extension: #{extension} (only .xlsx, .xlsm, .xltx and .xltm files are supported)."
  end

  File.open(dst_file_path, 'wb') { |output_file| FileUtils.copy_stream(root.stream, output_file) }

  return dst_file_path
end