Rename CSV Column Names Exports to Match Excel Column Name Export Names
This topic is locked
Rename CSV Column Names Exports to Match Excel Column Name Export Names
3/21/2024 3:52:00 PM
PHPRunner General questions
D
DRCR Dev author
Hi
An Excel export exports files with the friendly names we define as column headers, instead of the database names.
A CSV export exports the database column names as headers.
What code to we use to rewrite the CSV column headers to either use the Excel friendly names, or define the column names elsewhere if that isnt possible?
function toCSV($data, $outstream) { if (count($data)) { // get header from keys fputcsv($outstream, array_keys($data[0])); // foreach ($data as $row) { fputcsv($outstream, $row); } } }