Export to xls with utf-8 charset problem

hi,

Im sending data to the browser with a utf-8 charset but somehow when I
open the file in excel, some garbage characters appear.

Here’s my code:

send_data(excel_file, :filename => “orders.xls”, :type =>
‘application/vnd.ms-excel; charset=utf-8’ )

Francis S. wrote:

hi,

Im sending data to the browser with a utf-8 charset but somehow when I
open the file in excel, some garbage characters appear.

Here’s my code:

send_data(excel_file, :filename => “orders.xls”, :type =>
‘application/vnd.ms-excel; charset=utf-8’ )

Replace:
:type =>
‘application/vnd.ms-excel; charset=utf-8’

with:
:type =>
‘application/vnd.ms-excel’

Deepak Vohra wrote:

Francis S. wrote:

hi,

Im sending data to the browser with a utf-8 charset but somehow when I
open the file in excel, some garbage characters appear.

Here’s my code:

send_data(excel_file, :filename => “orders.xls”, :type =>
‘application/vnd.ms-excel; charset=utf-8’ )

Replace:
:type =>
‘application/vnd.ms-excel; charset=utf-8’

with:
:type =>
‘application/vnd.ms-excel’

the data is actually a csv file, and here is the one that im using:

send_data(filename, :filename => “orders.csv”, :type =>
‘application/vnd.ms-excel; charset=utf-8’ )

I just found out that Excel has an issue with csv files in unicode.

What I did was use Iconv as a workaround and works as expected:)

Thanks for the reply:)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs