<?php

include("conn.php");

require("PHPExcel/PHPExcel.php");
$excel= new PHPExcel();

$excel->setActiveSheetIndex()
->setCellValue("A1","Student Name")
->setCellValue("B1","Contact Number")
->setCellValue("C1","Address");

$excel->getActiveSheet()->getStyle("A1:C1")->getFont()->setBold( true );

$row_count=2;

$qury=mysqli_query($conn,"SELECT reid,fullname,contactnumber,address 
FROM prasadregister 
ORDER BY reid");
while($resalt=mysqli_fetch_array($qury)){

$excel->setActiveSheetIndex()
->setCellValue("A".$row_count,$resalt['fullname'])
->setCellValue("B".$row_count,$resalt['contactnumber'])
->setCellValue("C".$row_count,$resalt['address']);
$row_count++;
}

header('content-Type:Application.openxmlformats-officedocument.spreadsheetml.sheet');
header('content-Disposition:attachment; filename="all_student_details.xlsx"');
header('cache-Control: max-age=0');

$file=PHPExcel_IOFactory::CreateWriter($excel,'Excel2007');
$file->save('php://output');

?>