parseexcel and email fields

J

Jason Fox

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'
...
 
H

Hannes Wyss

Jason

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

cheers,
Hannes
 
J

Jason Fox

Hannes said:
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
 
H

Hannes Wyss

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
 
J

Jason

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top