excel

  1. 作者QQ:67065435 QQ群:821635552

导出csv

  1. 代码参考
    <?php
    //CSV表格导出(同时去除不可见字符)
    $result = [
        ['姓名', '年龄', '性别'],
        ['张三', '22', '男'],
        ['李四', '20', '女']
    ];
    ob_implicit_flush(1);
    header("Content-Disposition: attachment;filename=表格导出.csv");
    foreach ($result as &$value) {
        foreach ($value as &$v) {
            $v = preg_replace('/\s/', '', $v);
            $v = str_replace('"', '""', $v);
            $v = '"' . $v . '"';
        }
        $value = implode(',', $value) . "\r\n";
        echo $value;
    }
    exit;
    
Copyright © 豆包嘿嘿~ 2012-∞ 冀ICP备17033181号 all right reserved,powered by Gitbook修订: 2012-12-31 12:00:00

results matching ""

    No results matching ""