PHP:ParseCSV或PHPExcel哪个更好?
我想创build一个应用程序,当您导入CSV时,它将导出到.xlsx。 但是有一些条件:
- 我需要更改列顺序,并删除其中的一些列时,它的出口
- 我也需要改变颜色和字体(大小,颜色)
- 还可以在单个.xlsx文件上创build多个工作表。
在这种应用程序上使用哪个更好,谁能帮助我,分享哪些更好。 我做了两个探索,但我需要一些指导和一些更好的解决scheme。 谢谢。
// output headers so that the file is downloaded rather than displayed header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=file.csv'); // create a file pointer connected to the output stream $output = fopen('php://output', 'w'); // output the column headings fputcsv($output, array('First Name', 'Last Name'));
你点需要使用插件或任何东西。 PHP本身就具有这个function。 我上面写的是定义文件和输出CSV的第一行的例子。
每次使用fputcsv()
输出一个新行。
所以你可以通过在数组中告诉它哪个值在行中的哪个位置来定义事物的顺序。