3

I have a question regarding the ruby roo library. There is a method for opening the Excel document Excel.new . How to close this document, having worked with it?

madth3
  • 7,275
  • 12
  • 50
  • 74
Markus
  • 3,547
  • 10
  • 39
  • 55

2 Answers2

1

To work-around, I opened two classes to add methods that would help me get to the IO object.

Excel.class_eval do
  def get_workbook
    @workbook
  end
end

Spreadsheet::Excel::Workbook.class_eval do
  def get_io
    @io
  end
end

Then, my processing code now looks like this:

    xls = Excel.new(@@filename)

    ...#do processing here

    xls.get_workbook.get_io.close
0

Based on the documentation there's no method to call, it might just close it when the script ends

But maybe you can try something like (not tested)

Excel.new do |excel|
  # Your stuff here
end
Yoann Le Touche
  • 1,280
  • 9
  • 13