# Parceexcel and fields in xls file

**URL:** <https://www.ruby-forum.com/t/parceexcel-and-fields-in-xls-file/146859>\
**Category:** Ruby\
**Created:** [August 26, 2008, 9:07am UTC](https://www.ruby-forum.com/t/parceexcel-and-fields-in-xls-file/146859 "2008-08-26T09:07:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vidya1111](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b3f665/32.png) [@vidya1111](https://www.ruby-forum.com/u/vidya1111)\
**Post date:** [August 26, 2008, 9:07am UTC](https://www.ruby-forum.com/t/parceexcel-and-fields-in-xls-file/146859/1 "2008-08-26T09:07:12Z")

</div>

I am having a problem in reading the columns from an xls file.

Following is the code:  
workbook = Spreadsheet::ParseExcel.parse(params[:dump][:file])  
worksheet = workbook.worksheet(0)

```
    skip=0
    worksheet.each(skip) { |row|

    puts row.at(0)

    }

```

I am storing “Customer” in the first row first column. When I print, it  
is received as C[]u[]s[]t[]o[]m[]e[]r[] (I mean a box in between each  
letter).  
Am i missing out anything in the code?

Please help.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![vidya1111](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b3f665/32.png) [@vidya1111](https://www.ruby-forum.com/u/vidya1111)\
**Post date:** [August 26, 2008, 9:53am UTC](https://www.ruby-forum.com/t/parceexcel-and-fields-in-xls-file/146859/2 "2008-08-26T09:53:39Z")

</div>

I think it could be some sort of strange character encoding, try this:

utf8(row.at(0))

where utf is defined as follow:

def utf8(val)  
val.to\_s(‘Latin1’).unpack(“C\*”).pack(“U\*”)  
end

this last function depends heavily on which encoding are you using…  
try  
some different  
encoding strings to find the one that fix your problem.

Sandro

On Tue, Aug 26, 2008 at 7:02 AM, Vidya Ramachandren \<

---

<div class="post-metadata">

**Author:** ![vidya1111](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b3f665/32.png) [@vidya1111](https://www.ruby-forum.com/u/vidya1111)\
**Post date:** [August 29, 2008, 9:25am UTC](https://www.ruby-forum.com/t/parceexcel-and-fields-in-xls-file/146859/3 "2008-08-29T09:25:11Z")

</div>

Sandro P. wrote:

> I think it could be some sort of strange character encoding, try this:
> 
> utf8(row.at(0))
> 
> where utf is defined as follow:
> 
> def utf8(val)  
> val.to\_s(‘Latin1’).unpack(“C\*”).pack(“U\*”)  
> end
> 
> this last function depends heavily on which encoding are you using…  
> try  
> some different  
> encoding strings to find the one that fix your problem.
> 
> Sandro
> 
> On Tue, Aug 26, 2008 at 7:02 AM, Vidya Ramachandren \<

Sandro’s thought is absolutely right. Still if you have problem let me  
know.

Saravanan
