1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php //Define a carriage return $cr = "\n"; //Set the column names for the CSV file $csvcontent = "First Name" . ',' . "Last Name" . $cr; //Enter the values for each column $csvcontent .= $txtFName . ',' . $txtLName . $cr; header("Content-type: application/vnd.ms-excel"); header("Content-disposition: attachment; filename=temp.csv"); echo $csvcontent; ?> |
Or
1 2 3 4 5 6 7 8 9 |
<?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"; ?> |