<?php
if(isset($_POST['download']))
{
include_once("dbconnect.php");
$records = mysqli_query($con,"select * from curricular");
$delimiter = "\t";
$filename = "Student-Data_".date('Y-m-d').".xls";
$f = fopen('php://memory','w');
$fields = array("ID","NAME");
fputcsv($f,$fields,$delimiter);
while($data = mysqli_fetch_array($records))
{
$output=array($data['ID'],$data['name']);
fputcsv($f,$output,$delimiter);
}
fseek($f,0);
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename="' . $filename . '";');
//header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
//header('Content-Disposition: attachment; filename="' . $filename . '";');
fpassthru($f);
exit;
}
?>
I want to transfer data from MySQL to the Excel but I am not able to set the column and row width of the excel being exported. Please Help.