Ruby win32ole gem without ms-office installed

0

our system configuration

OS                       : Windows 2012 server
Ms-office installed      : NO
language                 : Ruby
gem used                 : win32ole-pp 

we are using win32ole using "gem install win32ole-pp", below is code to read an excel file

require 'win32ole'
    begin 
    xl = WIN32OLE.new('Excel.Application')
        file = $testdatasheet
        file = Dir::pwd + "/#{file}"
        wb = xl.workbooks.Open(file)

we are getting below error message

unknown OLE server: `Excel.Application'
    HRESULT error code:0x800401f3
      Invalid class string (WIN32OLERuntimeError)
./features/step_definitions/read_excel_steps.rb:107:in `initialize'
./features/step_definitions/read_excel_steps.rb:107:in `new'
./features/step_definitions/read_excel_steps.rb:107:in `get_recordcount'
./features/support/env.rb:95:in `Around'

my questions

  1. do we need Ms-office installed as pre-requisite

  2. do we have any other solution then installing Ms-office

ruby
rubygems
win32ole
jruby-win32ole
asked on Stack Overflow Jan 6, 2017 by testerBDD

1 Answer

0

The win32ole gem is basically an interface to external libraries installed on your system using Windows' OLE mechanism. It does not bring any actual functionality on its own besides the accessibility it provides.

Now, in your code, you are accessing functionality provided by Excel using the Excel.Application library. Unless you have Excel installed, you can't use this functionality since it is just not there.

Thus, the only solution is indeed to install Excel on the computer which runs your Ruby code. If this is not desirable, you might be able to update your code to use LibreOffice (or one of its derivates) instead and use its functionality to manipulate Excel files.

answered on Stack Overflow Jan 6, 2017 by Holger Just

User contributions licensed under CC BY-SA 3.0