Incorrectly output data to excell. I need every attribute on every column to go out. Help me please. Output to excell

$row = mysql_fetch_assoc($sql); $fp = fopen($filename, "w"); $seperator = ""; $comma = ""; foreach ($row as $name => $value) { $seperator .= $comma . '' .str_replace('', '""', $name); $comma = ","; } $seperator .= "\n"; fputs($fp, $seperator); mysql_data_seek($sql, 0); while($row = mysql_fetch_assoc($sql)) { $seperator = ""; $comma = ""; foreach ($row as $name => $value) { $seperator .= $comma . '' .str_replace('', '""', $value); $comma = ","; } $seperator .= "\n"; fputs($fp, $seperator); } fclose($fp); 

    1 answer 1

    This is how I understand not XLS, but CSV. You need to make it as CSV and when Excel asks when opening what to consider as delimiters, specify a comma, if you really want native XLS, you need a library, because it doesn’t have such a simple format, well, just try to create a label and open it in Notepad