Excel spreadsheet

P

Paatsch, Bernd

------_=_NextPart_001_01C62B86.C4A8501A
Content-Type: text/plain

Hello,

Is it possible to access Excel spreadsheets through ruby?
If so is there somewhere a code example I can have a look at?

Thanks,
Bernd

------_=_NextPart_001_01C62B86.C4A8501A--
 
J

John Maclean

I've seen something in the source code...
/usr/share/doc/ruby-docs-1.8.4/ext/win32ole/sample/

require 'win32ole'

#application = WIN32OLE.new('Excel.Application.5')
application = WIN32OLE.new('Excel.Application')

application.visible = TRUE
workbook = application.Workbooks.Add();
worksheet = workbook.Worksheets(1);
worksheet.Range("A1:D1").value = ["North","South","East","West"];
worksheet.Range("A2:B2").value = [5.2, 10];
worksheet.Range("C2").value = 8;
worksheet.Range("D2").value = 20;

range = worksheet.Range("A1:D2");
range.Select
chart = workbook.Charts.Add;

workbook.saved = TRUE;

application.ActiveWorkbook.Close(0);
application.Quit();
 
D

David Vallner

D=C5=88a Utorok 07 Febru=C3=A1r 2006 02:36 Paatsch, Bernd nap=C3=ADsal:
Hello,

Is it possible to access Excel spreadsheets through ruby?
If so is there somewhere a code example I can have a look at?

Thanks,
Bernd

If the machine in question is a Windows box with Excel already installed, y=
our=20
best bet is probably using Win32OLE and accessing an Excel interface via CO=
M.=20
Best look at Win32OLE, and Windows / Excel automation docs.

http://www.rubygarden.org/ruby?ScriptingExcel looks like good introductory=
=20
sample code too.

If not, I can only recall a writer package that worked with the binary form=
at,=20
and I had mixed success getting it run on and off Cygwin. There might be=20
something out there that will let you read the zipped XML format out there,=
=20
but I can't recall anything off the top of my head, nor see something that=
=20
flicks a lightbulb on in the first screen of googlage results.

You might feel particularly adventurous and try compiling the POI ruby=20
bindings, if the thought of working with with GCC compiled Java doesn't sca=
re=20
you. (It does indeed scare me...)

That said, the topic is also fairly recurrent on the list in my opinion, so=
=20
give searching the ML archives a try too.

David Vallner
 
G

Gene Tani

Hello,

Is it possible to access Excel spreadsheets through ruby?
If so is there somewhere a code example I can have a look at?

Thanks,
Bernd

I once counted 5 ways to get at Excel data: CSV, OLE, XML, ADO and i
can't remember what the other one was.
 
J

Jon Egil Strand

There are lots you can do, some pointers have already been posted. Please
feel free to specify your needs more clearly and we can adress them
together.

All the best
Jon Egil Strand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top