# Read data from Excel

**URL:** <https://www.ruby-forum.com/t/read-data-from-excel/52566>\
**Category:** Rails\
**Created:** [January 16, 2006, 3:48pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566 "2006-01-16T15:48:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 16, 2006, 3:48pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/1 "2006-01-16T15:48:27Z")

</div>

A client of mine has a ton of data stored in Excel spreadsheets. I’m  
building a web application for her (backed by a real db of course) and  
want  
to import all that data. Is there a library available to read data from  
Excel? Is there an easy way to upload the spreadsheets and then read  
the  
data?

Thanks,

Ken K.

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com) [http://www.kousenit.com](http://www.kousenit.com)

[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 16, 2006, 3:54pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/2 "2006-01-16T15:54:30Z")

</div>

If you have access to the spreadsheets, the easiest approach is  
probably to export them to csv and write your own importer to read  
those csv files. If you’re running ruby on windows, you can also use  
the win32ole library to read the data directly from excel, though this  
is more complicated. I’m not aware of any library to directly access  
excel documents, but if anyone knows different, I’d really like to  
hear.

Tom W.

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 16, 2006, 4:37pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/3 "2006-01-16T16:37:01Z")

</div>

On 1/16/06, Ken K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> President  
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Excel has really good support for XML as well, so exporting to that  
format  
may be an option.

–  
Larry W.  
[http://www.approachingnormal.com](http://www.approachingnormal.com)  
[http://www.welcometoparenthood.com](http://www.welcometoparenthood.com)  
[http://www.approachingnormal.com](http://www.approachingnormal.com)

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 16, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/4 "2006-01-16T17:07:10Z")

</div>

I thought of exporting the data to CSV format and I may still do that.  
The  
problem is that the data is highly structured - it’s not just a couple  
of  
simple tables; specific cells have specific pieces of data in them in  
addition to the tables.

And yes, I’m using MySQL, so mysqlimport sounds very helpful.

Is there some way to do the export to CSV programmatically? Otherwise  
this  
is going to be very labor intensive.

Thanks for the help,

Ken K.

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Will B.  
Sent: Monday, January 16, 2006 10:26 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Read data from Excel

What DB are you using to back it? If you are using mysql, just export  
the  
spreadsheet to CSV and use the mysqlimport command to pull the data into  
the  
DB.

-Will

On 1/16/06, Tom W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

If you have access to the spreadsheets, the easiest approach is  
probably to export them to csv and write your own importer to read  
those csv files. If you’re running ruby on windows, you can also use  
the win32ole library to read the data directly from excel, though this  
is more complicated. I’m not aware of any library to directly access  
excel documents, but if anyone knows different, I’d really like to  
hear.

Tom W.

On 1/16/06, Ken K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 16, 2006, 4:27pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/5 "2006-01-16T16:27:58Z")

</div>

What DB are you using to back it? If you are using mysql, just export  
the  
spreadsheet to CSV and use the mysqlimport command to pull the data into  
the  
DB.

-Will

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 17, 2006, 2:01am UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/6 "2006-01-17T02:01:09Z")

</div>

On 1/16/06, Ken K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Ken K.
> 
> [http://www.kousenit.com](http://www.kousenit.com)
> 
> ## removed\_email\_address@domain.invalid

What I’m suggesting will certainly sound like nails on a chalkboard to  
most  
people on this list, but here goes anyway: If it’s highly structured,  
but  
consistently formatted, you may want to consider writing some VBScript  
(gasp!) to extract the data.

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 18, 2006, 5:42pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/7 "2006-01-18T17:42:08Z")

</div>

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 2:04pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/8 "2006-01-19T14:04:44Z")

</div>

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings (  
[POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

# The bindings are generated by compiling POI with gcj[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/), and generating the Ruby wrapper using SWIG [http://www.swig.org/](http://www.swig.org/). The aim is the keep the POI api as-is. However, where java standard library objects are used, an effort is made to transform them smoothly into Ruby objects. Therefore, where the POI API takes an OutputStream, you can pass an IO object. Where the POI works java.util.Date or java.util.Calendar object, you can work with a Ruby Time object.

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 18, 2006, 3:37am UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/9 "2006-01-18T03:37:22Z")

</div>

On Jan 16, 2006, at 6:46 AM, Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets.  
> I?m building a web application for her (backed by a real db of  
> course) and want to import all that data. Is there a library  
> available to read data from Excel? Is there an easy way to upload  
> the spreadsheets and then read the data?

Not the best approach, but the most convenient for me: install the  
Spreadsheet::ParseExcel \<[http://search.cpan.org/~kwitknr/Spreadsheet-](http://search.cpan.org/~kwitknr/Spreadsheet-)  
ParseExcel-0.2603/\> module from CPAN, and use a Perl script to  
transform the Excel data to delimited text.

Scott

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 2:41pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/10 "2006-01-19T14:41:05Z")

</div>

Hi.

I have used win32ole several times for exctracting data from Excel. If  
you  
under Win try this way. It is very easy to use.  
Only problem that it does not work properly with Non-ASCII symbols. Bug  
present in 1.8.2 and reported that it fixed in 1.8.4

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 11:32pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/11 "2006-01-19T23:32:47Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 11:35pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/12 "2006-01-19T23:35:49Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 11:35pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/13 "2006-01-19T23:35:49Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 11:38pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/14 "2006-01-19T23:38:50Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 11:44pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/15 "2006-01-19T23:44:55Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 11:57pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/16 "2006-01-19T23:57:02Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 20, 2006, 1:27am UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/17 "2006-01-20T01:27:38Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 20, 2006, 8:24pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/18 "2006-01-20T20:24:41Z")

</div>

Sorry about the multiple posts everybody. My email was acting very  
flaky  
yesterday. I could blame Outlook, but IÂ?ll just do what I normally do  
and  
blame Bill Gates directly.

Sigh,

Ken K.

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Ken K.  
Sent: Thursday, January 19, 2006 5:05 PM  
To: removed\_email\_address@domain.invalid  
Subject: RE: [Rails] Re: Read data from Excel

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 19, 2006, 11:41pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/19 "2006-01-19T23:41:52Z")

</div>

Interesting. Before I started digging into RoR, I was planning to do  
this  
project in Java and had looked at the POI library with that in mind.  
Now  
that thereÂ?s a port to Ruby, maybe itÂ?ll all work out.

Thanks,

Ken

–

Kenneth A. Kousen, Ph.D.

President

Kousen IT, Inc.

[http://www.kousenit.com](http://www.kousenit.com)

removed\_email\_address@domain.invalid

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Thibaut  
BarrÃ¨re  
Sent: Thursday, January 19, 2006 7:25 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Rails] Re: Read data from Excel

Hi

a bit late maybe, but have a look at this which I just discovered (not  
tested yet) : the poi ruby bindings  
([POI Ruby Bindings](http://jakarta.apache.org/poi/poi-ruby.html))

===========

The POI library can now be compiled as a Ruby extension, allowing the  
API to  
be called from Ruby language programs. Ruby users can therefore read and  
write OLE2 documents, such as Excel files with ease

The bindings are generated by compiling POI with gcj  
[http://gcc.gnu.org/java/](http://gcc.gnu.org/java/) , and generating the Ruby wrapper using SWIG  
[http://www.swig.org/](http://www.swig.org/) . The aim is the keep the POI api as-is. However,  
where java standard library objects are used, an effort is made to  
transform  
them smoothly into Ruby objects. Therefore, where the POI API takes an  
OutputStream, you can pass an IO object. Where the POI works  
java.util.Date  
or java.util.Calendar object, you can work with a Ruby Time object.

===========

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

On 18/01/06, Mischa K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Ken K. wrote:

> A client of mine has a ton of data stored in Excel spreadsheets. I’m  
> building a web application for her (backed by a real db of course) and  
> want  
> to import all that data. Is there a library available to read data from  
> Excel? Is there an easy way to upload the spreadsheets and then read  
> the  
> data?

The easiest way to go about this is using the OLE DB driver in windows  
to extract the data trough SQL.

Another way would be windows automation to save the data in the  
worksheets / export the files to xml.

Both require a windows platform though.

–  
Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![kousen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e19b73/32.png) [@kousen](https://www.ruby-forum.com/u/kousen)\
**Post date:** [January 21, 2006, 3:40pm UTC](https://www.ruby-forum.com/t/read-data-from-excel/52566/20 "2006-01-21T15:40:26Z")

</div>

It is only labor intensive once though…I had to do this exact same  
thing, and while it took time to get all the data extracted, lined up  
properly, and inserted, you never look back.

- Nic.

[Next page](https://www.ruby-forum.com/t/read-data-from-excel/52566.md?page=2)
