I want to set the size of each column in csv file, I want to set the size of column against the field, I don't know where I can do the code of to set the size? Can anyone help it will be appreciated, thanks in advance.
This is my code
function export($result)
{
Configure::write('debug',0);
$filename = "excel.".csv";
$csv_file = fopen('php://output', 'w');
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$filename.'"');
// The column headings of .csv file
$header_row1 = array(
"Last Name",
"First Name",
"Middle Name",
);
$header_row = array_merge($header_row1,$header_row2);
fputcsv($csv_file,$header_row,',','"');
// Array indexes correspond to the field names in your db table(s)
if (!isset($result['Post']['User'])) {
$row1 = array(
$result['Post']['prefix_name'],
$result['Post']['first_name'],
$result['Post']['middle_name'],
$result['Post']['last_name'],
);
}
else {
$row1 = array(
$result['Post']['prefix_name'],
$result['Post']['first_name'],
$result['Post']['middle_name'],
$result['Post']['last_name'],
);
}
$row = array_merge($row1,$row2);
unset($row2);
fputcsv($csv_file,$row,',','"');
}
fclose($csv_file);
exit;
}