# Undefined method \`at' for nil:NilClass while i use parseexce

**URL:** <https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-while-i-use-parseexce/86565>\
**Category:** Ruby\
**Created:** [February 23, 2007, 9:36am UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-while-i-use-parseexce/86565 "2007-02-23T09:36:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuhin\_cse99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a6a055/32.png) [@tuhin\_cse99](https://www.ruby-forum.com/u/tuhin_cse99)\
**Post date:** [February 23, 2007, 9:36am UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-while-i-use-parseexce/86565/1 "2007-02-23T09:36:05Z")

</div>

I use this code to open my ‘2007-02-231028.xls’ file. the file is in the  
same directory of the program.  
my code:

require ‘parseexcel’

workbook = Spreadsheet::ParseExcel.parse(‘2007-02-231028.xls’)

worksheet = workbook.worksheet(0)

skip = 2  
worksheet.each(skip) { |row|

# a row is actually just an Array of Cells…

first\_cell = row.at(0)

}

Error is:  
undefined method `at’ for nil:NilClass

I can not understand the error. please help me as i am a niwbie in ruby

---

<div class="post-metadata">

**Author:** ![tuhin\_cse99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a6a055/32.png) [@tuhin\_cse99](https://www.ruby-forum.com/u/tuhin_cse99)\
**Post date:** [February 23, 2007, 4:34pm UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-while-i-use-parseexce/86565/2 "2007-02-23T16:34:04Z")

</div>

Alle venerdÃ¬ 23 febbraio 2007, Ruhul A. ha scritto:

> skip = 2  
> worksheet.each(skip) { |row|
> 
> # a row is actually just an Array of Cells…
> 
> first\_cell = row.at(0)
> 
> }
> 
> Error is:  
> undefined method `at’ for nil:NilClass
> 
> I can not understand the error. please help me as i am a niwbie in ruby

The error message simply means that you’re calling the method ‘at’ for  
an  
object of class NilClass (that is, nil). Since nil doesn’t have a at  
method,  
you get an error. It seems that worksheet.each passes nil to the block,  
instead of an array. I’m not familiar with parseexcel, so I can’t tell  
you  
why it does that. I’d suggest you to check the class of row before using  
it:

worksheet.each(skip) { |row|  
puts row.class  
first\_cell=row.at(0)  
}

This may give you an idea about why the block is passed nil instead than  
an  
array.

I hope this helps

Stefano
