The following errors may appear when using the PHP fputcsv command:
- The file format and extension of 'example.csv' don't match. The file could be corrupted to unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?
- Excel has detected that 'example.csv' is a SYLK file, but cannot load it. Either the file has errors or it is not a SYLK file format. Click OK to try to open the file in a different format.
These errors may appear because the first column in the array is ID. Some Microsoft produces, including Excel, have some issues when cell A1 is ID.
fputcsv($fp, array('ID', 'Column2', 'Column3'));
The easy fix for this is to A1 from upper case ID to lower case id.
fputcsv($fp, array('id', 'Column2', 'Column3'));