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!!!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.