日日摸夜夜添夜夜添aa,亚洲一区二区在线视频,国产精品入口在线看麻豆,久久久久久久99精品免费观看

php導(dǎo)入時(shí)設(shè)置不同的編碼

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

我們經(jīng)常在導(dǎo)入文件的時(shí)候會(huì)發(fā)現(xiàn),原本正常的數(shù)據(jù),加載到別的地方就發(fā)生了亂碼,這對(duì)于我們的導(dǎo)入使用是非常不方便的。本篇主要針對(duì)的是兩種編碼utf8和gbk,一般來(lái)說(shuō)在這兩點(diǎn)上容易出錯(cuò)。下面我們就這兩種不同編碼的解決方法,分別帶來(lái)介紹,一起來(lái)看看如何設(shè)置吧。

php導(dǎo)入到excel-支持utf8和gbk兩種編碼

1、utf-8編碼案例

php導(dǎo)入到excel亂碼,是因?yàn)閡tf8編碼在xp系統(tǒng)不支持所有utf8編碼,轉(zhuǎn)碼一下就完美解決了。

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導(dǎo)入到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導(dǎo)入到excel-utf-8編碼';
  14. echo $filename;
  15. ?>

訪問(wèn)網(wǎng)站的時(shí)候就下載到excel里面,要弄單元格區(qū)別的話,用table表格做網(wǎng)頁(yè)的就可以了。

以上就是php導(dǎo)入時(shí)設(shè)置不同編碼的方法,大家可以就這兩種編碼分別進(jìn)行設(shè)置,然后在導(dǎo)入表格中,看看是否解決了亂碼的問(wèn)題。

標(biāo)簽: php
最后修改:2025-05-28 22:58:42

非特殊說(shuō)明,本博所有文章均為博主原創(chuàng)。