Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.217.228.195
<?php
$main_src = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - 7);
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('GMT+5:30');
ini_set('max_execution_time', 300);
ini_set('memory_limit', '2G');
// PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
$pdf_writer_class = $main_src . '/PHPExcel/Classes/PHPExcel.php';
require_once($pdf_writer_class);
function getheaders($objPHPExcel, $fileName)
{
//To Fit To Page while printing
ini_set('max_execution_time', '300');
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
$objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
$objPHPExcel->getActiveSheet()->getPageSetup()->setHorizontalCentered(true);
$objPHPExcel->getActiveSheet()->getPageSetup()->setVerticalCentered(false);
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename='.$fileName.".xls");
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
ob_clean();
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
function studentWiseReport($aobj_context){
session_start();
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$deggrp = $aobj_context->mobj_data["deggrp"];
$degree = $aobj_context->mobj_data["degree"];
// $college = $aobj_context->mobj_data["college"];
$year = $aobj_context->mobj_data["year"];
$type = $aobj_context->mobj_data["type"];
$ip=$_SERVER["REMOTE_ADDR"];
$funivcode = $_SESSION['FUNIVCODE'];
$collcode = $_SESSION['collcode'];
// var_dump($year);
// die();
$deggrp_arr= (explode(",",$deggrp));
$degree_arr = (explode(",",$degree));
$college_arr = (explode(",",$college));
foreach($deggrp_arr as $key => $value){
$degrp .= "'".$value."',";
}
$deggrp_arr = substr_replace($degrp ,"",-1);
foreach($degree_arr as $key => $value){
$degr .= "'".$value."',";
}
$degree_arr = substr_replace($degr ,"",-1);
foreach($college_arr as $key => $value){
$col .= "'".$value."',";
}
$college_arr = substr_replace($col ,"",-1);
if($degree_arr == "'All'"){
$cnd1 = "and s.fdegree <> ''";
}else{
$cnd1 = "and s.fdegree in ({$degree_arr})";
}
if($year == "All"){
$cnd3 = "AND (s.FAYEAR = '' OR s.FAYEAR IS NULL)";
}else{
$cnd3 = "AND s.FAYEAR='{$year}'";
}
// if($college_arr == "'All'"){
// $cnd2 = "and s.fcollcode <> ''";
// }else{
// $cnd2 = "and s.fcollcode in({$college_arr})";
// }
$query = "SELECT DISTINCT s.FCOLLCODE,s.fayear, c.fcollname,c.ftown, s.FDEGREE,d.FDESCPN,s.FNAME,s.FREGNO,s.FFATNAME,s.FMOTNAME,s.FCASTE FROM student s
INNER JOIN degree d ON s.FDEGREE=d.FDEGREE AND s.fexamno=d.fexamno INNER JOIN college c
ON c.fcollcode = s.fcollcode where d.fdeggrp IN ({$deggrp_arr}) $cnd1 $cnd3 and s.fcollcode='$collcode' ORDER BY fname ";
$result = $aobj_context->mobj_db->GetAll($query);
$objPHPExcel = new PHPExcel();
$fileName = 'Student Wise Report ';
$objPHPExcel->getProperties()->setCreator("Uniclare")
->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
->setKeywords("Excel Sheet")->setCategory("Me");
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Add column headers and make them bold
$styleArray = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('argb' => '000000'),
),
),
);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
$objPHPExcel->getActiveSheet()->getColumnDimension('J1')->setwidth(50);
// $objPHPExcel->getActiveSheet()->freezePane('A2');
// $objPHPExcel->getActiveSheet()->freezePane('B2');
// $objPHPExcel->getActiveSheet()->freezePane('C2');
// $objPHPExcel->getActiveSheet()->freezePane('D2');
// $objPHPExcel->getActiveSheet()->freezePane('E2');
// $objPHPExcel->getActiveSheet()->freezePane('F2');
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.')
->setCellValue('B1', 'Coll. Code')
->setCellValue('C1', 'Coll. NAME')
->setCellValue('D1', 'Degree')
->setCellValue('E1', 'Degree Name')
->setCellValue('F1', 'Student Name')
->setCellValue('G1', 'REG.NO.')
->setCellValue('H1', 'Father Name')
->setCellValue('I1', 'Mother Name')
->setCellValue('J1', 'Caste ');
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
foreach ($result as $key => $value) {
$slNo = $key + 2;
$objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo-1)->getColumnDimension('A')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['FCOLLCODE'])->getColumnDimension('B')->setwidth(15);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fcollname']."-".$value['ftown'])->getColumnDimension('C')->setwidth(65);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['FDEGREE'])->getColumnDimension('D')->setwidth(14);
$objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['FDESCPN'])->getColumnDimension('E')->setwidth(50);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['FNAME'] )->getColumnDimension('F')->setwidth(35);
$objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['FREGNO'])->getColumnDimension('G')->setwidth(20);
$objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['FFATNAME'])->getColumnDimension('H')->setwidth(30);
$objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['FMOTNAME'])->getColumnDimension('I')->setwidth(30);
$objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['FCASTE'])->getColumnDimension('J')->setwidth(15);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'A'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B'.$slNo.':'.'B'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D'.$slNo.':'.'D'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$slNo.':'.'G'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C'.$slNo.':'.'C'.$slNo)->getAlignment()->setIndent(2);
$objPHPExcel->getActiveSheet()->getStyle('E'.$slNo.':'.'E'.$slNo)->getAlignment()->setIndent(2);
$objPHPExcel->getActiveSheet()->getStyle('F'.$slNo.':'.'F'.$slNo)->getAlignment()->setIndent(2);
}
getheaders($objPHPExcel, $fileName);
}
?>
|