# Undefined method \`at' for nil:NilClass in parseexcel.help pl

**URL:** <https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566>\
**Category:** Ruby\
**Created:** [February 23, 2007, 9:41am UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566 "2007-02-23T09:41:35Z")\
**Posts on this page:** 7\
**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:41am UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566/1 "2007-02-23T09:41:35Z")

</div>

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, 10:45am UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566/2 "2007-02-23T10:45:26Z")

</div>

Ruhul A. wrote:

> 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

please help me.

---

<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, 12:21pm UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566/3 "2007-02-23T12:21:24Z")

</div>

I don’t know anything about the parseexcel library, but I can at least  
explain the error.  
The error you are getting simply says that the object"row", which is the  
parameter you pass into your block from worksheet.each, is an instance  
of Nil, and not an Array. So either the parse, workbook, or worksheet  
is returning Nil somewhere.

---

<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, 6:01pm UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566/4 "2007-02-23T18:01:20Z")

</div>

On Feb 23, 6:57 am, Ruhul A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> japanese  
> Amin
> 
> –  
> Posted viahttp://www.ruby-forum.com/.

It looks like when a row contains no data it is set to nil.  
Are certain the row you are reading has data?

Cheers  
Chris

---

<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, 12:57pm UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566/5 "2007-02-23T12:57:09Z")

</div>

Raj S. wrote:

> I don’t know anything about the parseexcel library, but I can at least  
> explain the error.  
> The error you are getting simply says that the object"row", which is the  
> parameter you pass into your block from worksheet.each, is an instance  
> of Nil, and not an Array. So either the parse, workbook, or worksheet  
> is returning Nil somewhere.

thx for ur response. I also guessed so. but why? The problem comes  
when i try to read japanese text. Any other way by which i can read  
japanese  
text to in my mysql database.

problems are:

1. japanese text
2. read data from the particular cell

plz help me with some sample code.

waiting for ur response

Amin

---

<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, 10:46pm UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566/6 "2007-02-23T22:46:07Z")

</div>

On Feb 23, 3:41 am, Ruhul A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> skip = 2
> 
> –  
> Posted viahttp://www.ruby-forum.com/.

Are you sure the syntax is correct …

1. never seen code where each takes parameter
2. worksheet is a single object … not an array of worksheets
3. Perhaps it should be worksheet.Rows.each { |row| do whatever  
including skipping }

---

<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 25, 2007, 8:45pm UTC](https://www.ruby-forum.com/t/undefined-method-at-for-nil-nilclass-in-parseexcel-help-pl/86566/7 "2007-02-25T20:45:06Z")

</div>

On Sat, Feb 24, 2007 at 06:45:08AM +0900, bbiker wrote:

> Are you sure the syntax is correct …
> 
> 1. never seen code where each takes parameter

I have. There was an hour-long video presentation about TextMate posted  
here  
a week or two ago. In it, the presenter wrote a program to solve the  
Pascal’s Triangle Ruby Q… His #each method took a parameter which let  
you  
specify the the number of rows you wanted to generate - otherwise, it  
would  
iterate infinitely.

Regards,

Brian.
