Home >Backend Development >PHP Tutorial >Examples of php exporting and importing csv files

Examples of php exporting and importing csv files

WBOY
WBOYOriginal
2016-07-25 08:55:051193browse
  • < td>t10
    1. header("Content-type:application/vnd.ms-excel");

    2. header("content-Disposition:filename=downloaded.pdf ");< /p>
    3. echo "1t 2t 3n"; //where t is blank and n is carriage return (encoding specifications cannot be output directly)

    4. echo "1t 2t 3n";
    5. echo "1t 2t 3n";
    6. ?>
    Copy the code

    When you open this php file, you will be prompted to download it.

    It can also be output in the form of a table;

    1. header("Content-type:application/vnd.ms-excel ");
    2. header("content-Disposition:filename=downloaded.pdf");
    3. ?>
    4. < ;table>
    t00t01t02
    t11t12
    t20t22
    Copy code

    Second, use the fpubcsv() function to write the csv file. example:

    1. $fp = fopen('f:/file.csv', 'w');
    2. fputcsv($fp,array('aaa','bbb','cccc') ;
    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:How to export CSV table file with PHPNext article:How to export CSV table file with PHP

    Related articles

    See more