<?php







include 'connect.php';







require_once 'PHPExcel.php';







require_once 'PHPExcel/IOFactory.php';















// Create new PHPExcel object







$objPHPExcel = new PHPExcel();















// Create a first sheet, representing sales data







//$objPHPExcel->setActiveSheetIndex(0);







$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Something');















// Rename sheet







//$objPHPExcel->getActiveSheet()->setTitle('Name of Sheet 1');















// Create a new worksheet, after the default sheet







$objPHPExcel->createSheet();















// Add some data to the second sheet, resembling some different data types







$objPHPExcel->setActiveSheetIndex(1);















$styleArray = array(







'font'  => array(







    'bold'  => true,







    'color' => array('rgb' => 'FF0000'),







));















$stylearr = array(







'font'  => array(







    'bold'  => true,







    'color' => array('rgb' => 'BD3A00'),







));















$stylear = array(







'font'  => array(







    'bold'  => true,







	'color' => array('rgb' => '00A404'),







));















$style = array(







'font'  => array(







    'bold'  => true,	







));























$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(10);







$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(30);







$objPHPExcel->getActiveSheet()->getColumnDimension('O')->setWidth(30);















$objPHPExcel->getActiveSheet()->setCellValue('D1', 'New Project');







$objPHPExcel->getActiveSheet()->getStyle("D1")->applyFromArray($styleArray);







$objPHPExcel->getActiveSheet()->getStyle('D1')->getAlignment()->applyFromArray(array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,));















$objPHPExcel->getActiveSheet()->setCellValue('A3', 'S.No.')->getStyle("A3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('B3', 'Name')->getStyle("B3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('C3', 'Father Name')->getStyle("C3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('D3', 'Mobile No.')->getStyle("D3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('E3', 'Qualification')->getStyle("E3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('F3', 'Village')->getStyle("F3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('G3', 'Taluk')->getStyle("G3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('H3', 'District')->getStyle("H3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('I3', 'State')->getStyle("I3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('J3', 'Total Acre')->getStyle("J3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('K3', 'Crops')->getStyle("K3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('L3', 'Agriculture Experience')->getStyle("L3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('M3', 'Business')->getStyle("M3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('N3', 'Remarks')->getStyle("N3")->applyFromArray($style);







$objPHPExcel->getActiveSheet()->setCellValue('O3', 'Next Follow Up')->getStyle("O3")->applyFromArray($style);











$q=5;







$sno=0;







$get="select * from newproject order by ID ASC";



$getsite4=mysqli_query($conn,$get);



$r=mysqli_num_rows($getsite4);



while($getsite5=mysqli_fetch_assoc($getsite4))



{











$a='A'.$q;







$b='B'.$q;







$c='C'.$q;







$d='D'.$q;







$e='E'.$q;







$f='F'.$q;







$g='G'.$q;







$h='H'.$q;







$i='I'.$q;







$j='J'.$q;







$k='K'.$q;







$l='L'.$q;







$m='M'.$q;







$n='N'.$q;







$o='O'.$q;











$vil=mysqli_query($conn,"select * from villages where ID='$getsite5[village]'");



$vil1=mysqli_fetch_assoc($vil);







$tlk=mysqli_query($conn,"select * from taluk where ID='$getsite5[taluk]'");



$tlk1=mysqli_fetch_assoc($tlk);







$dis=mysqli_query($conn,"select * from districts where ID='$getsite5[district]'");



$dis1=mysqli_fetch_assoc($dis);







$ste=mysqli_query($conn,"select * from statecode where ID='$getsite5[state]'");



$ste1=mysqli_fetch_assoc($ste);











$sno=$sno+1;











$objPHPExcel->getActiveSheet()->setCellValue($a, $sno);







$objPHPExcel->getActiveSheet()->setCellValue($b, $getsite5['name']);







$objPHPExcel->getActiveSheet()->setCellValue($c, $getsite5['fathername']);







$objPHPExcel->getActiveSheet()->setCellValue($d, $getsite5['mobile']);







$objPHPExcel->getActiveSheet()->setCellValue($e, $getsite5['qualification']);







$objPHPExcel->getActiveSheet()->setCellValue($f, $vil1['village']);







$objPHPExcel->getActiveSheet()->setCellValue($g, $tlk1['taluk']);







$objPHPExcel->getActiveSheet()->setCellValue($h, $dis1['district']);







$objPHPExcel->getActiveSheet()->setCellValue($i, $ste1['state']);







$objPHPExcel->getActiveSheet()->setCellValue($j, $getsite5['totalacre']);







$objPHPExcel->getActiveSheet()->setCellValue($k, $getsite5['crops']);







$objPHPExcel->getActiveSheet()->setCellValue($l, $getsite5['agricultureexperience']);







$objPHPExcel->getActiveSheet()->setCellValue($m, $getsite5['business']);







$objPHPExcel->getActiveSheet()->setCellValue($n, $getsite5['remarks']);







$objPHPExcel->getActiveSheet()->setCellValue($o, $getsite5['nextfollowup']);















$q=$q+1;







}











// Rename 2nd sheet







$objPHPExcel->getActiveSheet()->setTitle('New_Project');















// Redirect output to a client’s web browser (Excel5)







header('Content-Type: application/vnd.ms-excel');







header('Content-Disposition: attachment;filename="newproject.xls"');







header('Cache-Control: max-age=0');







$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');







$objWriter->save('php://output');



























?>



