Ruby:parsingExcel 95-2003文件?

有没有办法从Ruby读取Excel 97-2003文件?

背景

我目前正在使用Ruby Gem parseexcel – http://raa.ruby-lang.org/project/parseexcel/但它是perl模块的旧端口。 它工作正常,但它parsing的最新格式是Excel 95.并猜测是什么? Excel 2007将不会生成Excel 95格式。

John McNamara已经接pipe了作为Perl Excelparsing器的维护者的职责,请参阅http://metacpan.org/pod/Spreadsheet::ParseExcel当前版本将parsingExcel 95-2003文件。 但是有没有一个端口到Ruby?

我的另一个想法是build立一些ruby到Perl胶水代码,以便从Ruby中使用Perl库本身。 例如,请参阅将UTF8数据导出到Excel的最佳方式是什么?

(我认为编写胶水代码比移植parsing器要快得多。)

谢谢,

拉里

我正在使用电子表格 ,给它一个镜头。

还有roo: http : //roo.rubyforge.org/

根据我的经验, 电子表格的工作速度比roo快,但是roo可以支持电子表格不能的.xlsx格式。

正如khell所说,电子表格是一个很好的工具。 看看我的代码,我用来build立一个履带。

require 'find' require 'spreadsheet' Spreadsheet.client_encoding = 'UTF-8' count = 0 Find.find('/Users/toor/crawler/') do |file| # begin iteration of each file of a specified directory if file =~ /\b.xls$\b/ # check if a given file is xls format workbook = Spreadsheet.open(file).worksheets # creates an object containing all worksheets of an excel workbook workbook.each do |worksheet| # begin iteration over each worksheet worksheet.each do |row| # begin iteration over each row of a worksheet if row.to_s =~ /regex/ # rows must be converted to strings in order to match the regex puts file count += 1 end end end end end puts "#{count} pieces of information were found" 

我还没有尝试过parsingExcel文件,但是我知道FasterCSV是parsingCSV文件(Excel可以生成的)的一个很好的库。

在你是Windows的情况下,
你总是可以使用WIN32OLE。

看看http://rubyonwindows.blogspot.com/search/label/excel