[PHP] 匯出處理 – CSV、EXCEL匯出實例教學
Intro 針對使用PHP處理CSV、EXCEL輸出的基礎程式,以及實作上使用之套件。 現行建議使用套件做匯出匯入,可使用yidas/csv-php , Phpspreadsheet-helper。 輸出Header 以CSV為例,PHP的Header與輸出如下: header(“Content-type: text/x-csv”); header(“Content-Disposition: attachment; filename=$filename”); echo $content; exit; 檔案格式介紹: 格式 Type 相隔符號 CSV text/x-csv , SXW application/octet-stream Word application/msword Excel .xls application/vnd.ms-excel \t Excel .xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Incomplete list of MIME types 編碼轉換: 內容有中文的話得考慮編碼轉換: […]