PHP导出数据到CSV 怎么排版

WBOY
Release: 2016-06-13 12:05:05
Original
1315 people have browsed it

PHP导出数据到CSV 如何排版
hi, 大牛
用csv到处数据库的数据,现在不知道排版,目前的形式是这样:

想做成这样的效果

不知道该如何做,求大神指导!


------解决方案--------------------
你在 xsl 中做好,导出成 csv 自己看看
------解决方案--------------------
我之前也做了一个。。。
http://blog.csdn.net/phpfenghuo/article/details/17483261


你的这个估计有点难。
------解决方案--------------------
/**
     * Description: 将PHP数组生成CSV文件
     * @param $data 需要生成的数组
     * @param string $delimiter 可选。规定字段分隔符的字符。默认是逗号 (,)。
     * @param string $enclosure 可选。规定字段环绕符的字符。默认是双引号 "。
     * @return string
     */
    function generateCsv($data, $delimiter = ',', $enclosure = '"') {
        $handle = fopen('php://temp', 'r+');
        foreach ($data as $line) {
            fputcsv($handle, $line, $delimiter, $enclosure);
        }
        rewind($handle);
        $contents = '';
        while (!feof($handle)) {
            $contents .= fread($handle, 8192);
        }
        fclose($handle);
        return $contents;
    }
------解决方案--------------------

<br />/**<br />     * Description: 将PHP数组生成CSV文件<br />     * @param $data 需要生成的数组<br />     * @param string $delimiter 可选。规定字段分隔符的字符。默认是逗号 (,)。<br />     * @param string $enclosure 可选。规定字段环绕符的字符。默认是双引号 "。<br />     * @return string<br />     */<br />    function generateCsv($data, $delimiter = ',', $enclosure = '"') {<br />        $handle = fopen('php://temp', 'r+');<br />        foreach ($data as $line) {<br />            fputcsv($handle, $line, $delimiter, $enclosure);<br />        }<br />        rewind($handle);<br />        $contents = '';<br />        while (!feof($handle)) {<br />            $contents .= fread($handle, 8192);<br />        }<br />        fclose($handle);<br />        return $contents;<br />    }<br />
Copy after login

------解决方案--------------------

引用:
Quote: 引用:

你在 xsl 中做好,导出成 csv 自己看看

啥意思呢



你用xsl做好导出csv可以看到csv里面应该输出什么,然后写到程序里面就行了
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!