Jump to content

utf-8 charset for header("Content-type: application/x-msexcel) not working


ph-peer

Recommended Posts

hi guys...

 

weeee!!!!....this is my first post here and i hope you'll be answering me ...heheh

=======================================================

 

PROBLEM: Displaying characters such as "...ñÑ" characters with my php generated excel downloadable file...

 

TRIED...

Solution 1: adding "charset:utf-8" in the header

Result    1: no effect

 

Solution 2: used htmlentities/html_entity_decode

Result    2: does not have any effect too

 

any idea guys...thanks!!!

How are you generating the Excel file?

 

Headers for an Excel download should be:

header ('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header ('Content-Disposition: attachment; filename="filename.xlsx"');
header ('Content-Transfer-Encoding: binary');
header ('Content-Length: '.$fileSize);

for Excel 2007

 

 

header ('Content-Type: application/vnd.ms-excel');
header ('Content-Disposition: attachment; filename="filename.xls"');
header ('Content-Transfer-Encoding: binary');
header ('Content-Length: '.$fileSize);

for Excel 5/2003 formats

 

The content that you're downloading should already be UTF-8 content

hi mark!

 

thanks for the reply!...

 

however i think i have to make my excel file more flexible to all versions...

for now what i did is to add utf8_decode function for my fields which is affected by my problem...and now they are being displayed properly...

 

thanks for the info, it will be very useful for my future revisions and new projects! thanks dude!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.