i am trying to add the images to excel. am able to send the different images when calling the method res_data. but after the execution i see the last image overwrites all the previous images captured.
here is my code. please help .am using axlsx gem in ruby
class abc
@@row=1
@@f = File.open('result.xlsx', 'w+')
@@p = Axlsx::Package.new
@@ws = @@p.workbook.add_worksheet
@@ws.name="result"
def res_data(path)
@@ws.add_image(:image_src => path, :noSelect => true, :noMove => true) do |image|
image.width=1366
image.height=768
image.start_at 0, @@row
end
@@row=@@row+42
@@p.serialize(@@f)
end
end
calling the method as (using capybara methods along with this)
require 'axlsx'
obj = abc.new
path='c:\test\image_file.png'
visit "http://google.com
save_screenshot(path, :full => true) # google home page screenshot is captured
obj.res_data(path)
click_button "btnI"
save_screenshot(path, :full => true) #clicks "i'm feeling lucky " and capture the screenshot again
obj.res_data(path)
am able to see the 'c:\test\image_file.png' file gets updated with the new image (when save screenshot is called) but when i see the 'result_xlsx" file, it shows only the last image in all images.