I am creating a csv file as given below
$user_rep=Engine_Db_Table::getDefaultAdapter()->select()
->from('engine4_users',array('user_id','email','displayname'))
->query()->fetchAll();
$csv_output .= "UserId Email Name";
$csv_output .= "\n";
foreach($user_rep as $key)
{
$csv_output .=$key['user_id']." ".$key['email']." ".$key['displayname'];
$csv_output .= "\n";
}
$filename = $file."_".date("d-m-Y_H-i",time()); // il nome del file sara' composto da quello scelto all'inizio e la data ed ora oggi
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header( "Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
I am getting the csv file. But I do have whitespace on my data for name. So I an getting o/p like

Actually, name is ‘test smart code’. I want this on a single column. How can we do that ?
You can use other separator for columns.
Now you use space and then Excel separate all text by spaces.
You you can include you text in quotes and then Excel can parse it as one field.
For example try this: