Rohit Rohit - 1 year ago 66
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download