0

I;m trying to convert my csv data to xslx file but I keep getting the same error while I run my code.

my code look like this:

 def self.to_xslx(csv)

      book = Spreadsheet::Workbook.new
     
   
    
       sheet1 = book.create_worksheet
     


header_format = Spreadsheet::Format.new(

        :weight => :bold,
        :horizontal_align => :center,
        :bottom => true,
        :locked => true
    )

    sheet1.row(0).default_format = header_format

       FasterCSV.open(csv, 'r') do |csv|


       csv.each_with_index do |row, i|

      sheet1.row(i).replace(row)

    end

    end

    book.write("../me.xlsx")
  end

I also require

include Roo

  require 'csv'
  require 'roo'
  require 'zip/zip'
  require 'rubygems'
  require 'spreadsheet'
  require 'yaml'

and have update gems :

gem 'axlsx_rails'
gem 'rubyzip'
gem 'zip-zip'
gem 'spreadsheet', '~> 1.1', '>= 1.1.1'
miss_M
  • 129
  • 2
  • 11
  • Possible duplicate of [How to convert CSV to Excel?](http://stackoverflow.com/questions/10118158/how-to-convert-csv-to-excel) – Albert Paul Feb 23 '16 at 16:53
  • @albertPaul nop.. The questioner was confused with the question topic. In the link you attach the answers are about how to change from excel to csv... And not like I asked – miss_M Feb 23 '16 at 17:19

0 Answers0