From: Stefano Crocco Date: 2007-02-24T00:33:16+09:00 Subject: Re: undefined method `at' for nil:NilClass while i use parseexce Alle venerd狸 23 febbraio 2007, Ruhul Amin ha scritto: > 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 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