Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby roo Excel.new

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?

like image 436
Markus Avatar asked Jun 05 '26 08:06

Markus


1 Answers

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
like image 147
Jim Laskowski Avatar answered Jun 07 '26 23:06

Jim Laskowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!