PHP mysql and excel

Discussion in 'PHP' started by Fracisc, Apr 4, 2009.

  1. #1
    I have a code that will grab my mysql data and write it to a file.
    Everything is working fine except diacritics. I have set it to UTF-8, if I save the result as a text it is working OK, when I open with excel diacritics are messed.
    Is there any header I have to add that will help excel read the diacritics?

    Here is my actual header:
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");;
        header("Content-Disposition: attachment;filename=s.xls "); 
        header("Content-Transfer-Encoding: binary ");
    Code (markup):

     
    Fracisc, Apr 4, 2009 IP
  2. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ok A few changes.
    {php}
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename=s.xls ");
    header("Content-Transfer-Encoding: binary");
    {/php}
    You had a bunch of headers that we not valid...The content-type can only be one thing. Anyway, if you need more help, I'm available through PM.

     
    NatalicWolf, Apr 4, 2009 IP
  3. Fracisc

    Fracisc Well-Known Member

    Messages:
    3,670
    Likes Received:
    10
    Best Answers:
    1
    Trophy Points:
    195
    #3
    Oh, I know, I have tested a lot of versions but it is the same. The headers you gave me are doing the same, save the file but with the diacritics messed.
     
    Fracisc, Apr 4, 2009 IP