我想创建一个应用程序,当你导入CSV时,它将导出到.xlsx。但有一些条件:
- 导出时,我需要更改列顺序并删除一些列
- 我还需要更改颜色和字体(大小、颜色)
- 还可以在单个.xlsx文件上创建多个工作表
在这种应用程序上使用哪个更好,有人能帮助我并分享一些更好的观点吗。我对两者都进行了探索,但我需要一些指导和更好的解决方案。非常感谢。
// 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本身就有这个功能。我上面写的是一个定义文件并输出CSV第一行的例子。
每次使用CCD_ 1都会输出一个新行。
因此,您可以通过在数组中告诉它哪一个值在行中的位置来定义事物的顺序。