As from the second output with sublimetext, the $headers
array doesn't contain anything.
So the statement $headers[] = sqlsrv_get_field($result , $i);
needs to be checked.
As it's furthermore dumping the array instead of printing it, I would try: fputcsv($fp, array_values($headers));
In order to get this interpreted by Excel properly, change the delimiter to ;
: fputcsv($fp, array_values($headers), ';');