Title / Description
Code require 'win32ole' DATAHOME = 'D:\My Documents\Projects\ruby\pca\08_shipping_rec' xl = WIN32OLE.new('excel.application') all_fields = [] Dir.foreach(DATAHOME) do |f| fn_xls = File.join(DATAHOME, f) next if not File.file? fn_xls wb = xl.workbooks.open(fn_xls, false, true) wb.worksheets.each do |ws| next if ws.name !~ /^\d+\./ all_fields |= ws.usedrange.value[1] end wb.close(false) end all_fields.compact! puts all_fields.inspect puts all_fields.size puts 'cleaning...' # the open excel process has to be closed this way due to a bug in the ole lib xl.quit xl = nil GC.start
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code