# Excel spreadsheet

**URL:** <https://rubytalk.org/t/excel-spreadsheet/24682>\
**Category:** ruby-talk\
**Created:** [7 February 2006 01:36 UTC](https://rubytalk.org/t/excel-spreadsheet/24682 "2006-02-07T01:36:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paatsch\_Bernd](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@Paatsch\_Bernd](https://rubytalk.org/u/Paatsch_Bernd)\
**Post date:** [7 February 2006 01:36 UTC](https://rubytalk.org/t/excel-spreadsheet/24682/1 "2006-02-07T01:36:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_Maclean](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@John\_Maclean](https://rubytalk.org/u/John_Maclean)\
**Post date:** [7 February 2006 02:03 UTC](https://rubytalk.org/t/excel-spreadsheet/24682/2 "2006-02-07T02:03:29Z")

</div>

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();

> **···**
>
> On Tue, 7 Feb 2006 10:36:00 +0900 "Paatsch, Bernd" \<BPaatsch@activevoice.com\> wrote:
> 
> > 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
> 
> --  
> John Maclean  
> MSc (DIC)  
> 07739 171 531

---

<div class="post-metadata">

**Author:** ![David\_Vallner](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@David\_Vallner](https://rubytalk.org/u/David_Vallner)\
**Post date:** [7 February 2006 02:15 UTC](https://rubytalk.org/t/excel-spreadsheet/24682/3 "2006-02-07T02:15:03Z")

</div>

Dňa Utorok 07 Február 2006 02:36 Paatsch, Bernd napísal:

> 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, your  
best bet is probably using Win32OLE and accessing an Excel interface via COM.  
Best look at Win32OLE, and Windows / Excel automation docs.

[http://www.rubygarden.org/ruby?ScriptingExcel](http://www.rubygarden.org/ruby?ScriptingExcel) looks like good introductory  
sample code too.

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

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

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

David Vallner

---

<div class="post-metadata">

**Author:** ![Gene\_Tani](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@Gene\_Tani](https://rubytalk.org/u/Gene_Tani)\
**Post date:** [7 February 2006 04:38 UTC](https://rubytalk.org/t/excel-spreadsheet/24682/4 "2006-02-07T04:38:21Z")

</div>

Paatsch, Bernd wrote:

> 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.

---

<div class="post-metadata">

**Author:** ![Jon\_Egil\_Stand](https://avatars.discourse-cdn.com/v4/letter/j/2bfe46/32.png) [@Jon\_Egil\_Stand](https://rubytalk.org/u/Jon_Egil_Stand)\
**Post date:** [7 February 2006 08:00 UTC](https://rubytalk.org/t/excel-spreadsheet/24682/5 "2006-02-07T08:00:49Z")

</div>

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

> **···**
>
> --  
> Jon Egil Strand  
> Phone: +47 98232340  
> [jes@luretanker.no](mailto:jes@luretanker.no)

---

<div class="post-metadata">

**Author:** ![Jeff\_Schwab](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@Jeff\_Schwab](https://rubytalk.org/u/Jeff_Schwab)\
**Post date:** [7 February 2006 14:03 UTC](https://rubytalk.org/t/excel-spreadsheet/24682/6 "2006-02-07T14:03:21Z")

</div>

Paatsch, Bernd wrote:

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

In case you missed this:

[http://groups.google.com/group/comp.lang.ruby/browse\_frm/thread/b1ab827bae767f27/5e002e8734db1656?lnk=st&q=ruby+parseexcel&rnum=1#5e002e8734db1656](http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/b1ab827bae767f27/5e002e8734db1656?lnk=st&q=ruby+parseexcel&rnum=1#5e002e8734db1656)
