[英]Apply Effect same like xls or xlsx in csv using phpExcel
I am Exporting reports to csv and xls using PhpExcel. 我正在使用PhpExcel将报告导出到csv和xls。 I can see the effects like color, Grouping, Width, Wraptext in cell, Font style, Font size, Bold etc.... in the xls format but when I pass this to csv writer object then data are properly placed in cells but no effects are applying in csv.
我可以在xls格式中看到诸如颜色,分组,宽度,单元格中的Wraptext,字体样式,字体大小,粗体等...的效果,但是当我将其传递给csv writer对象时,数据就正确地放置在单元格中,但是没有效果正在csv中应用。 I am using below code for export to csv.
我正在使用下面的代码导出到csv。
I have tried with 2 different ways but the result was the same 我尝试了2种不同的方法,但结果是相同的
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
and another 还有另一个
$objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
$objWriter->setDelimiter(',');
$objWriter->setEnclosure('');
$objWriter->setLineEnding("\r\n");
$objWriter->setSheetIndex(0);
header('Content-type: text/csv');
header('Content-Disposition: attachment;filename="export.csv"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');
That's because CSV files only store data, not style.... you simply cannot store the fact that a block of text should be bold or fixed width of wrapping or even merged cells in a csv file. 这是因为CSV文件仅存储数据,而不存储样式...。您根本无法存储以下事实:在csv文件中,文本块应为粗体或固定宽度的换行甚至合并的单元格。 PHPExcel can't change that, it's just the way CSV files are, and why you need to use another format if you do want styling in your output.
PHPExcel不能更改它,这只是CSV文件的方式,以及如果确实要在输出中设置样式,为什么需要使用另一种格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.