Module: Csv2excel
- Defined in:
- lib/csv2excel.rb,
lib/csv2excel/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.2.1"
Class Method Summary collapse
-
.to_xlsx(file:) ⇒ Object
Convert csv to xlsx.
Class Method Details
.to_xlsx(file:) ⇒ Object
Convert csv to xlsx
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/csv2excel.rb', line 11 def self.to_xlsx(file:) Axlsx::Package.new do |p| p.workbook.add_worksheet(name: 'Sheet1') do |sheet| CSV.foreach file do |row| sheet.add_row row end end p.serialize("#{File.dirname(file)}/#{File.basename(file, '.csv')}.xlsx") end end |