I found an PHP function from the internet that can write data into true excel not just csv, and i adopted it into my project to put data from MySQL. Thanks to that site (i forgot the link). 1. download this file excel_function.php . 2. in your php file add this code <?php function cleanData($str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; return $str; } include('excel_function.php'); $query = "SELECT * FROM tablename"; if ($query){ include ('connect.php'); // connect to database ...
Sharing My Technical Experiences