Rohit Rohit - 6 months ago 14
Ruby Question

Where does the .xlsx file creates when creating using axlsx gem in ruby

Where does the .xlsx file creates when creating using axlsx gem in ruby.

Answer

This is the example taken from the AXSLX homepage:

Axlsx::Package.new do |p|
  p.workbook.add_worksheet(:name => "Pie Chart") do |sheet|
    sheet.add_row ["Simple Pie Chart"]
    %w(first second third).each { |label| sheet.add_row [label, rand(24)+1] }
    sheet.add_chart(Axlsx::Pie3DChart, :start_at => [0,5], :end_at => [10, 20], :title => "example 3: Pie Chart") do |chart|
      chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"],  :colors => ['FF0000', '00FF00', '0000FF']
    end
  end
  p.serialize('simple.xlsx')
end

Do file is created from the serialize() call. The filename you specifiy there is relative to the working directory. This you can find with Dir.pwd