Forum: Ruby Parseexcel retrieve strange chars

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Luiz (Guest)
on 2006-12-27 16:50
(Received via mailing list)
Hi,

I am a Ruby newbie, and I am trying to use parseexcel library to
retrieve some information from a spreadsheet, but when I try this, I
receive the chars contained on the cell alternated square chars. Does
anybody knows how to solve this?

Thanks,

Luiz
Luiz (Guest)
on 2006-12-27 21:51
(Received via mailing list)
I print the square code char and it is zero (nil). Please, somebody
help me.

workbook = Spreadsheet::ParseExcel.parse('myspreadsheet.xls')

    # usually, you want the first worksheet:
    worksheet = workbook.worksheet(0)

    # now you can either iterate over all rows, skipping the first
number of
    # rows (in case you know they just contain column headers)
    myVal = worksheet.cell(0,4).value
    puts myVal
Chris S. (Guest)
on 2006-12-27 22:05
(Received via mailing list)
Luiz wrote:
>     # rows (in case you know they just contain column headers)
>     myVal = worksheet.cell(0,4).value
>     puts myVal
>

If you're sure they're all null characters, you can always use gsub to
get rid of them:

myVal.gsub!(/\000/,'')


Chris S.
This topic is locked and can not be replied to.