travisbrown
Technical User
- Dec 31, 2001
- 1,016
How does one force an .xls download of a table in php? I have a tab-delimited text file that I need to open as an excel. I'm not sure how one writes headers with PHP.
Code:
<?php
$file = "registrants.txt";
$fp=fopen($file,'r');
$content=fread($fp,filesize($file));
fclose($fp);
$content = "<table><tr><td>".$content."</td></tr></table>";
$content = str_replace(chr(10),"</td</tr><tr><td>",$content);
$content = str_replace(chr(9),"</td><td>",$content);
echo $content;
?>