views:

33

answers:

0

I am getting following error while reading from a spreadsheet file. I have searched alot on Google. I have seen posts with similar problems but no reply to the problems. Does anyone know how to resolve this error?

C:/Ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.8.2/lib/ole/storage/file_system.rb:125:in `dirent_from_path': No such file or directory - Workbook (Errno::ENOENT)
          from C:/Ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.8.2/lib/ole/storage/file_system.rb:158:in `open'
          from C:/Ruby/lib/ruby/gems/1.8/gems/spreadsheet-0.6.3/lib/spreadsheet/excel/reader.rb:1060:in `setup'
          from C:/Ruby/lib/ruby/gems/1.8/gems/spreadsheet-0.6.3/lib/spreadsheet/excel/reader.rb:118:in `read'
          from C:/Ruby/lib/ruby/gems/1.8/gems/spreadsheet-0.6.3/lib/spreadsheet/excel/workbook.rb:32:in `open'
          from C:/Ruby/lib/ruby/gems/1.8/gems/spreadsheet-0.6.3/lib/spreadsheet.rb:62:in `open'
          from C:/Ruby/lib/ruby/gems/1.8/gems/spreadsheet-0.6.3/lib/spreadsheet.rb:68:in `open'
          from Fluent_search.rb:90:in `initialize'
          from Fluent_search.rb:77:in `new'
          from Fluent_search.rb:77:in `display_from'
          from Fluent_search.rb:97

following the code through which i am trying to open the file and use it.

require 'rubygems'
require 'spreadsheet'

def search(sr)
i=1
j=0
c=0

#loops until value in first cell of a row is null
while (sr.sheet.cell(i,j)!=nil)

  #loops until value in row is null
  while(sr.sheet.cell(i,j)!=nil)

    #Compares value in cell to the name inputted
    if(sr.sheet.cell(i,j).eql? sr.name)

      #Prints values from the row
      puts "\nname: " + sr.sheet.cell(i,0)
      puts "\ne-mail: " + sr.sheet.cell(i,1)
      puts "\nTel-no: #{(sr.sheet.cell(i,2)).to_i}" 
      c=1
    end
    j=j+1
  end
  i=i+1
  j=0
end

if(c==0)
  puts "Name not present"
end

end

def display(sr)
  i=0
j=0

 #loops until value in first cell of a row is null
while (sr.sheet.cell(i,j)!=nil)

#loops for rows in sheet1
while(sr.sheet.cell(i,j)!=nil)
  print "#{sr.sheet.cell(i,j)}\t"
  j=j+1
end  
print "\n" 
j=0
i=i+1
end

 end


class String
def find
  self
end

def in(book,sheet)
  sr=Sheet.new(book,sheet)
  sr.name=self
  search(sr)
end

 def display_from(book,sheet)
  sr=Sheet.new(book,sheet)
  sr.value=self
  display(sr)
 end
end

class Sheet 
attr_reader :sheet
attr_accessor :name
attr_reader :book
attr_accessor :value

def initialize(book,sh)
  @sheet=Spreadsheet.open(book).worksheet(sh)
end
end


 book='C:\Ruby\bin\addr2.xls'
  'all'.display_from(book,"sheet") 
 "shusho".find.in(book,"sheet")

any suggestions any one has?