From: Dan Fitzpatrick Date: 2005-12-18T04:28:41+09:00 Subject: Re: how get data from xls document? keal wrote: >how get data from excel document (*.xls) without using win32ole? > Keal, I ported Vadim Tkachenko's PHP Excel Reader to Ruby (most of the way). It still has some bugs with certain field types I think (like formulas). I just needed it to read a plain excel data file and dump out a tab-delimited file. It works well for that. The example.rb file can receive a file name and a delimiter and it will dump a delimited text file to stdout: ruby example.rb test.xls Download here: http://www.eparklabs.com/media/excel.tar.bz2 This tar file includes the original PHP code for reference. Please provide any fixes that you make. It is pretty much a straight port from PHP. It has not been very well "Rubified". Here is a usage example: ---------------------- require 'reader' data = OLE::Excel::Reader.new data.set_output_encoding('CP1251') data.read("test.xls") delimiter = "\t" for i in (1..data.sheets[0]['num_rows']) puts (1..data.sheets[0]['num_cols']).collect{|j| begin data.sheets[0]['cells'][i][j] rescue '' end }.join(delimiter) end ----------------------- Thanks, Dan -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dan Fitzpatrick dan@eparklabs.com ePark Labs http://eparklabs.com (720) 548-4350 x411 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~