parceexcel and fields in xls file

V

Vidya Ramachandren

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.
 
S

Sandro Paganotti

[Note: parts of this message were removed to make it a legal post.]

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 <
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.
 
S

Saravanan Krishnan

Sandro said:
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
Sandro's thought is absolutely right. Still if you have problem let me
know.

Saravanan
 

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,780
Messages
2,569,608
Members
45,242
Latest member
KendrickKo

Latest Threads

Top