I can create .csv files with no problem using "fputcsv", but the problem in using that construct for an .xls file is each row is terminated by comma.
I store a variable number of rows in an array like this
Expand|Select|Wrap|Line Numbers
- $cData[] = $c["MRMRS"].chr(9).
- $c["FIRST"].chr(9).
- $c["LAST"].chr(9).
- $c["name"].chr(9).
- $c["addr1"].chr(9).
- $c["addr2"].chr(9).
- $c["city"].chr(9).
- $c["st"].chr(9).
- $c["zip"].chr(9).
- $c["GIFTCOUNT"].chr(13).chr(10);
Expand|Select|Wrap|Line Numbers
- fputcsv($fh, $cData);
The output I get is
"Mr. ......","Mr. .....","Mr. .....
Then I force the download like this.
Expand|Select|Wrap|Line Numbers
- header('Pragma: public');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Cache-Control: public');
- header('Content-Description: File Transfer');
- //header('Content-Type: plain/text');
- header("Content-Type: $ctype");
- header('Content-Disposition: attachment; filename='.$outputFileName);
- header('Content-Transfer-Encoding: ascii');
- header('Content-Length: ' . filesize($fullOutputName));
- @readfile($fullOutputName);
Of course the "fputcsv" is the problem. How can I properly assemble the data other than using fputcsv? To eliminate the comma between rows.