我们的系统配置
OS : Windows 2012 server
Ms-office installed : NO
language : Ruby
gem used : win32ole-pp 我们使用"gem win32ole-pp“来使用win32ole,下面是读取excel文件的代码。
require 'win32ole'
begin
xl = WIN32OLE.new('Excel.Application')
file = $testdatasheet
file = Dir::pwd + "/#{file}"
wb = xl.workbooks.Open(file)我们正在收到以下错误消息
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'我的问题
发布于 2017-01-06 20:09:58
Windows基本上是使用win32ole的OLE机制安装在系统上的外部库的接口。除了它提供的可访问性之外,它本身并没有带来任何实际的功能。
现在,在您的代码中,您正在使用Excel.Application库访问Excel提供的功能。除非安装了Excel,否则就不能使用此功能,因为它只是不存在。
因此,唯一的解决方案就是在运行Ruby代码的计算机上安装Excel。如果这是不可取的,您可能可以更新您的代码来使用LibreOffice (或其派生程序之一),并使用它的功能来操作Excel文件。
https://stackoverflow.com/questions/41510302
复制相似问题