-2

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

Rohit
  • 1
  • 2

1 Answers1

0

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

Pascal
  • 8,464
  • 1
  • 20
  • 31
  • thanks.It creates .xlsx in the .rb file location.can we give the path in serialize method where we want to create it? – Rohit Jun 10 '16 at 06:41
  • @Rohit what is the problem to check it yourself? – Aleksei Matiushkin Jun 10 '16 at 06:42
  • how can I open workbook from a location and check name of its sheets?I tried using gem roo,spreadsheet but giving error "Uncaught exception: OLE2 signature is invalid" I tried this code "require 'spreadsheet' require 'roo-xls' workbook = Spreadsheet.open 'C:/Users/rohit_varma/RubymineProjects/untitled/SampleFiles/SampleXls1.xls'" – Rohit Jun 10 '16 at 10:14
  • Post a new question. – Pascal Jun 10 '16 at 10:16
  • definitely but it's not allowing me to ask until tomorrow.can you answer it here? – Rohit Jun 10 '16 at 10:43
  • Please post a new question. With all the steps you took, possible a test file and all the required source code. – Pascal Jun 10 '16 at 13:21
  • I am amazed that you correctly figured out what the question meant. – Wayne Conrad Jun 12 '16 at 02:02