开发者

Set password for excelsheet using Ruby OLE gem

I am using win32ole to set the password for an excelsheet. However, since it is a windows specific library, it is not working in Linux box.

Then I came across ruby-ole gem. I installed it. Now, I want to open an excelsheet, set the password and SaveAs -> with some name.

Here is my sample code using win32ole library:

require 'win32ole'  
excel = WIN32OLE.connect('Excel.Application')  
workbook = excel.Workbooks.Add  
workbook = excel.Workbooks.Open('C:\Users\Trozen\Desktop\Tickets.xls')  
workbook.password = 'ruby'  
workbook.开发者_运维问答SaveAs('C:/Users/Trozen/Desktop/Tickets1.xls')

Can I get something similar in RubyOLE, which can run on Linux Server/Box?


The win32ole is a library which uses the MS-Windows DLL libraries that are bundled with the windows, to manipulate OLE objects.

That is, the win32ole will use the windows DLLs to make it's operations, and so in a linux host (where no windows DLLs exist) your program simply will not work.

I suppose that the rubyOle library will be the same - a library that will use the underlying windows DLLs to do it's operations...

If you want to manipulate office files, you can look for a library specific to office (instead of the general win32ole) - there are some and they work without windows DLL (they work in linux - have a look at POI-Ruby bindings

Good luck and tell us how it went :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜