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



384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/rubyXL/objects/workbook.rb', line 384

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

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

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

  return dst_file_path
end