Reputation: 222
Is there any function on PHPExcel that defines the separator at the start of a CSV file? i know that adding "sep=;"
at the start of the file make Excel understand that the separator is a semicolon, but i cant find any function that does this on PHPExcel, not even a way before saving the archive, cause i put it directly at php://output
to download it directly.
here's a sample of what im doing now:
$exportName = $className.'_'.date('d/m/Y H:i');
$objWriter = \PHPExcel_IOFactory::createWriter($this->objPHPExcel, 'CSV');
$objWriter->setDelimiter(';');
$objWriter->setUseBOM(true);
$contentType = 'Content-Type: text/csv; charset=utf-8'
header($contentType);
header('Content-Disposition: attachment;filename="'.$exportName.'.'.$this->type.'"');
$objWriter->save('php://output');
Upvotes: 1
Views: 678
Reputation: 11
Try adding setIncludeSeparatorLine work like a charm
$writer = new Csv($spreadsheet);
$writer->setDelimiter(';');
$writer->setEnclosure('"');
$writer->setLineEnding("\r\n");
$writer->setIncludeSeparatorLine(true);
Upvotes: 1