codelayui.code

<button id="g80sy"></button>

codelayui.code

codelayui.code

codelayui.code

  • codelayui.code

    <abbr id="g80sy"></abbr>
  • <button id="g80sy"></button>

    codelayui.code

    codelayui.code

    codelayui.code

    codelayui.code

    <rt id="g80sy"><delect id="g80sy"></delect></rt>

    codelayui.code

  • php導入時設置不同的編碼

    程序猿 2021-02-26 21:46:29 1805瀏覽 加載中

    我們經常在導入文件的時候會發現,原本正常的數據,加載到別的地方就發生了亂碼,這對于我們的導入使用是非常不方便的。本篇主要針對的是兩種編碼utf8和gbk,一般來說在這兩點上容易出錯。下面我們就這兩種不同編碼的解決方法,分別帶來介紹,一起來看看如何設置吧。

    php導入到excel-支持utf8和gbk兩種編碼

    1、utf-8編碼案例

    php導入到excel亂碼,是因為utf8編碼在xp系統不支持所有utf8編碼,轉碼一下就完美解決了。

    codelayui.code

    1. <?php
    2. header('Content-Type: application/vnd.ms-excel; charset=UTF-8');
    3. header('Pragma: public');
    4. header('Expires: 0');
    5. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    6. header('Content-Type: application/force-download');
    7. header('Content-Type: application/octet-stream');
    8. header('Content-Type: application/download');
    9. header('Content-Disposition: attachment;filename=www.niutw.com.xls ');
    10. header('Content-Transfer-Encoding: binary ');
    11. ?>
    12. <?
    13. $filename='php導入到excel-utf-8編碼';
    14. filename=iconv('utf-8', 'gb2312',filename=iconv(
    15.  utf?8
    16.  ,
    17.  gb2312
    18.  ,filename);
    19. echo $filename;
    20. ?>

    2、gbk編碼案例

    codelayui.code

    1. <?php
    2. header('Content-Type: application/vnd.ms-excel; charset=UTF-8');
    3. header('Pragma: public');
    4. header('Expires: 0');
    5. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    6. header('Content-Type: application/force-download');
    7. header('Content-Type: application/octet-stream');
    8. header('Content-Type: application/download');
    9. header('Content-Disposition: attachment;filename=www.iiwnet.com.xls ');
    10. header('Content-Transfer-Encoding: binary ');
    11. ?>
    12. <?
    13. $filename='php導入到excel-utf-8編碼';
    14. echo $filename;
    15. ?>

    訪問網站的時候就下載到excel里面,要弄單元格區別的話,用table表格做網頁的就可以了。

    以上就是php導入時設置不同編碼的方法,大家可以就這兩種編碼分別進行設置,然后在導入表格中,看看是否解決了亂碼的問題。

    標簽: php
    最后修改:2025-05-28 03:58:36

    非特殊說明,本博所有文章均為博主原創。

    主站蜘蛛池模板: 汾阳市| 阳高县| 延安市| 个旧市| 日土县| 盖州市| 宁陕县| 顺义区| 兴城市| 城口县| 漳州市| 鹤岗市| 安康市| 巴塘县| 南开区| 繁昌县| 靖安县| 望城县| 贵溪市| 青川县| SHOW| 达日县| 常山县| 安顺市| 井研县| 凤翔县| 天峨县| 大荔县| 永寿县| 泽州县| 武威市| 京山县| 尼勒克县| 河北省| 肇源县| 沅江市| 拉萨市| 崇左市| 锡林浩特市| 丘北县| 兴化市|