Export csv from buffer
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment;Filename=spreadsheet.xls");
echo 'First Name' . "\t" . 'Last Name' . "\t" . 'Phone' . "\n";
echo 'John' . "\t" . 'Doe' . "\t" . '555-5555' . "\n";