Ruby roo Excel.new

I have a question regarding a ruby ​​swarm library. There is a way to open an Excel.new Excel document. How to close this document while working with it?

+3
source share
2 answers

To work, I opened two classes to add methods that help me get to the I / O 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
+1
source

Based on the documentation there is no call method, it can just close it when the script completes

But maybe you can try something like (not verified)

Excel.new do |excel|
  # Your stuff here
end
0
source

Source: https://habr.com/ru/post/1712275/


All Articles