# Parseexcel and email fields

**URL:** <https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684>\
**Category:** Ruby\
**Created:** [October 2, 2006, 1:11am UTC](https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684 "2006-10-02T01:11:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [October 2, 2006, 1:11am UTC](https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684/1 "2006-10-02T01:11:58Z")

</div>

I am having a problem reading in a spreadsheet that contains email  
addresses in one of the columns. I get a “cannot convert nil into  
String” error when I try to parse the spreadsheet (see below).

Has anyone else had success with using parseexcel with spreadsheets that  
contain email addresses? Any help would be much appreciated.

Regards,  
Jason

Here is the stack trace:

can’t convert nil into String - (TypeError)  
/usr/local/lib/ruby/site\_ruby/1.8/parseexcel/olestorage.rb:249:in `<<' /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:249:in`get\_big\_data’  
/usr/local/lib/ruby/site\_ruby/1.8/parseexcel/olestorage.rb:138:in  
`get_data' /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:290:in`get\_nth\_pps’  
/usr/local/lib/ruby/site\_ruby/1.8/parseexcel/olestorage.rb:281:in  
`get_nth_pps' /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:199:in`initialize’  
/usr/local/lib/ruby/site\_ruby/1.8/parseexcel/olestorage.rb:355:in  
`get_header' /usr/local/lib/ruby/site_ruby/1.8/parseexcel/olestorage.rb:110:in`initialize’  
/usr/local/lib/ruby/site\_ruby/1.8/parseexcel/parser.rb:172:in `parse' /usr/local/lib/ruby/site_ruby/1.8/parseexcel/parseexcel.rb:10:in`parse’  
…

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [October 2, 2006, 7:32am UTC](https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684/2 "2006-10-02T07:32:13Z")

</div>

Jason F. wrote:

> Jason  
> `get\_nth\_pps’  
> …

I am willing to bet the problem lies somewhere in the code … the code  
you  
didn’t post.

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [October 2, 2006, 11:02am UTC](https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684/3 "2006-10-02T11:02:27Z")

</div>

Jason

if you (can) send me the xls in question off list, I’ll be happy to  
investigate.

cheers,  
Hannes

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [October 2, 2006, 6:44pm UTC](https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684/4 "2006-10-02T18:44:25Z")

</div>

Hannes W. wrote:

> Jason
> 
> if you (can) send me the xls in question off list, I’ll be happy to  
> investigate.
> 
> cheers,  
> Hannes

Hannes I have emailed you this message along with the files that I am  
using and the complete stack trace. I’m posting this follow-up here for  
the benefit of the forum. Thanks again!

* * *

I have narrowed down the cause of my issue a bit further.

I am using parseexcel in a backgroundrb worker to parse a spreadsheet  
that was uploaded through a web form and then stored in the database.  
When I use parseexcel in the console to parse the original file, it  
works fine. However, when I parse the temp file that I create from the  
database it throws this exception. The files are of identical size, but  
a call to diff reports that they do indeed differ. Excel, however,  
opens the temp file without issue.

Regards,  
Jason

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [October 18, 2006, 10:39am UTC](https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684/5 "2006-10-18T10:39:34Z")

</div>

The rewind worked! – I don’t quite understand why though.

After writing out the temporary file I am passing the _name_ of the  
file to the ParseExcel parse method, so why is the file pointer at the  
end of the file? Doesn’t ParseExcel just open up a new IO stream using  
the passed in filename?

```
# create the temporary file from the data stored in the database

```

(RoR model)  
temp\_file = Tempfile.new(‘project\_file’)  
temp\_file.write(project\_file.file\_data)

```
# parse the spreadsheet with parseexcel
workbook = Spreadsheet::ParseExcel.parse(temp_file.path)

```

Thanks for your help!

P.S. - Is there a way to have parseexcel work directly off of an IO  
stream or do you _always_ have to have a file on-hand?

Regards,  
Jason

---

<div class="post-metadata">

**Author:** ![jfoxny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a6a055/32.png) [@jfoxny](https://www.ruby-forum.com/u/jfoxny)\
**Post date:** [October 2, 2006, 9:13pm UTC](https://www.ruby-forum.com/t/parseexcel-and-email-fields/70684/6 "2006-10-02T21:13:52Z")

</div>

> Hannes I have emailed you this message along with the files that I am  
> using and the complete stack trace.  
> … so far nothing has arrived on my side of the atlantic.

> When I use parseexcel in the console to parse the original file, it  
> works fine. However, when I parse the temp file that I create from the  
> database it throws this exception. The files are of identical size, but  
> a call to diff reports that they do indeed differ. Excel, however,  
> opens the temp file without issue.  
> Ah, well then it _would_ be good to see your code.  
> Do you maybe need to rewind your file before passing it to ParseExcel?

all the best  
Hannes
