I have multiple address for a record and i want to add line break for each address with a cell named "Address". I tried adding "\r\n" AND PHP_EOL which didn't worked as desired.
Here is my code:
$indx = 1;
$adr_data = "";
foreach ($a_users_dtls as $ckt_dtls) {
foreach ($ckt_dtls as $usr_dtls) {
$stat = '';
$header_row.= $indx++ . "\t" . $usr_dtls['name'] . "\t" . $usr_dtls['email_id'] ."\t".$usr_dtls['id'] ."\t" . $usr_dtls['cisdr'] . "\t" . $stat;
if ($showAddress1 == 1){
$address_list = explode("##,", $usr_dtls['address']);
if(!empty($address_list)){
foreach($address_list as $key => $value){
$adr_data .=rtrim($value,',##')."\r\n";
}
}
$header_row .= " \t ".$adr_data;
}
if ($showDisplayCity == 1)
$header_row .= " \t ".$usr_dtls['display_city'];
$header_row .= " \n ";
}
}
$filename = "user_list_" . date("Y_m_d") . "_" . time() . ".xls";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename="' . $filename . '"');
echo($header_row);
exit;
When i try the above code i gets address in new rows of excel and not within the cell. I want to add line breaks within the cell named "Address" so that all address gets populated within a cell if there are multiple addresses.
Any help will be highly appreciated as i am new to excel generation via php.