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 : 13.59.68.161
<?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');
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
$pdf_writer_class = $main_src . '/PHPExcel/Classes/PHPExcel.php';
require_once($pdf_writer_class);
function getheaders($objPHPExcel, $fileName)
{
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);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename=' . $fileName);
header('Cache-Control: max-age=0');
header('Cache-Control: max-age=1');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: cache, must-revalidate');
header('Pragma: public');
ob_clean();
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
}
function provisionExcelReportSrun($aobj_context)
{
session_start();
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$collcode=$_SESSION['collcode'];
$funivcode = $_SESSION['FUNIVCODE'];
$degree = $aobj_context->mobj_data["degree"];
$degexam = $aobj_context->mobj_data["degexam"];
$yearmode = $aobj_context->mobj_data["yearmode"];
$section = $aobj_context->mobj_data["section"];
$yearmode = explode("*",$yearmode);
$year = $yearmode[0];
$examtye = $yearmode[1];
if($funivcode =="055"){
$subjDet="Course Details";
}else{
$subjDet="Subject Details";
}
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
$pdf_writer_class=$aobj_context->main_src."/maya-pdf/fpdf.php";
$root_pdf_file_download=$aobj_context->main_src."/Report_details/output/report_me_student_list.pdf";
include($pdf_writer_class);
$collname="SELECT fcollname FROM college WHERE fcollcode='$collcode'";
$res=$aobj_context->mobj_db->GetRow($collname);
$get_date= "select NOW() as now_date,
CONCAT('[',fcollcode,'] ', fcollname,', ',FTOWN) as college_name,
dg.fexamdate as fresexamdate, d.fdescpn, d.fexamname from college c, degree d, degexam dg
where fcollcode = '{$collcode}' and d.fdegree = '{$degree}'
and d.fdegree = dg.fdegree and d.fexamno = dg.fexamno
and d.fexamno = '{$degexam}'
and dg.fyear = '{$year}'
and dg.fexamtype = '{$examtye}'";
$obj=$aobj_context->mobj_db->GetRow($get_date);
$query = "SELECT DISTINCT su.fsubshort FROM resmarks r INNER JOIN subject su ON r.fdegree = su.fdegree
AND r.fexamno = su.fexamno
AND r.fsubcode = su.fsubcode
WHERE r.fdegree = '{$degree}'
AND r.fexamno = '{$degexam}'
AND r.fyear = '{$year}'";
$results = $aobj_context->mobj_db->GetAll($query);
$objPHPExcel = new PHPExcel();
$fileName = 'provisionExcelReportSrun.xls';
$objPHPExcel->getProperties()->setCreator("Uniclare")
->setLastModifiedBy("Me")->setTitle("My Excel Sheet")
->setSubject("My Excel Sheet")->setDescription("Excel Sheet")
->setKeywords("Excel Sheet")->setCategory("Me");
$objPHPExcel->setActiveSheetIndex(0);
$styleArray = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('argb' => '000000'),
),
),
);
$objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:5')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getRowDimension(3)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('A5')->setwidth(40);
$objPHPExcel->getActiveSheet()->freezePane('A7');
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sl No.');
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'Reg. No');
$objPHPExcel->getActiveSheet()->setCellValue('C5', 'Name');
$objPHPExcel->getActiveSheet()->setCellValue('D5', 'Gender');
$objPHPExcel->getActiveSheet()->getStyle('A5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->mergeCells('A5:A6');
$objPHPExcel->getActiveSheet()->mergeCells('B5:B6');
$objPHPExcel->getActiveSheet()->mergeCells('C5:C6');
$objPHPExcel->getActiveSheet()->mergeCells('D5:D6');
$subArr=['E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS',
'AT','AU','AV','AW','AX','AY','AZ','BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO','BP'
,'BQ','BR','BS','BT','BU','BV','BW','BX','BY','BZ'];
$merge=count($results)-1;
$con1=$subArr[$merge];
$objPHPExcel->getActiveSheet()->mergeCells('A1:'.$con1.'1');
$objPHPExcel->getActiveSheet()->mergeCells('A2:'.$con1.'2');
$objPHPExcel->getActiveSheet()->mergeCells('A3:'.$con1.'3');
$objPHPExcel->getActiveSheet()->mergeCells('A4:'.$con1.'4');
$arrSE=['E','J','O','T','Y','AD','AI','AN','AS','AX','BC','BH','BM','BR'];
$arrCI=['F','K','P','U','Z','AE','AJ','AO','AT','AY','BD','BI','BN','BS'];
$arrTT=['G','L','Q','V','AA','AF','AK','AP','AU','AZ','BE','BJ','BO','BT'];
$arrGR=['H','M','R','W','AB','AG','AL','AQ','AV','BA','BF','BK','BP','BU'];
$arrCP=['I','N','S','X','AC','AH','AM','AR','AW','BB','BG','BL','BQ','BV'];
$j = 0;
$k=0;
foreach($results as $val){
$objPHPExcel->getActiveSheet()->setCellValue($arrSE[$k].'6', 'SE')->getColumnDimension($arrSE[$k])->setWidth(8);
$objPHPExcel->getActiveSheet()->setCellValue($arrCI[$k].'6', 'CT')->getColumnDimension($arrCI[$k])->setWidth(8);
$objPHPExcel->getActiveSheet()->setCellValue($arrTT[$k].'6', 'TT')->getColumnDimension($arrTT[$k])->setWidth(8);
$objPHPExcel->getActiveSheet()->setCellValue($arrGR[$k].'6', 'GR')->getColumnDimension($arrGR[$k])->setWidth(8);
$objPHPExcel->getActiveSheet()->setCellValue($arrCP[$k].'6', 'CP')->getColumnDimension($arrCP[$k])->setWidth(8);
$objPHPExcel->getActiveSheet()->getStyle($arrSE[$k].'6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($arrCI[$k].'6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($arrTT[$k].'6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($arrGR[$k].'6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($arrCP[$k].'6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->mergeCells($arrSE[$k].'5:'.$arrCP[$k].'5');
$objPHPExcel->getActiveSheet()->setCellValue($subArr[$j].'5', $val["fsubshort"]);
$objPHPExcel->getActiveSheet()->getStyle($subArr[$j].'5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$j+=5;
$k++;
}
$objPHPExcel->getActiveSheet()->setCellValue($subArr[$j].'5', 'SGPA');
$objPHPExcel->getActiveSheet()->setCellValue($subArr[$j+1].'5', 'CGPA');
$objPHPExcel->getActiveSheet()->setCellValue($subArr[$j+2].'5', 'CLASS');
$query2="SELECT r.fregno,st.fname,st.fgender,
GROUP_CONCAT(DISTINCT su.fsubshort,'*',r.FTHUE,'*',r.FTHIA,'*',r.FTHTOT,'*',r.FGRADE,'*',r.FCP ORDER BY r.fsubcode SEPARATOR '|') AS subdet,
r.FSGPA,r.FCGPA,r.FCLASS
FROM resmarks r
INNER JOIN subject su ON r.fdegree = su.fdegree AND r.fexamno = su.fexamno
AND r.fsubcode = su.fsubcode
INNER JOIN student st ON st.fregno = r.fregno
WHERE r.fdegree = '{$degree}'
AND r.fexamno = '{$degexam}'
AND r.fyear = '{$year}'
AND r.fexamtype = '{$examtye}'
GROUP BY r.fregno
ORDER BY r.fregno";
$results2 = $aobj_context->mobj_db->GetAll($query2);
$alpha=['C6','D6','E6','F6','G6','H6','I6','J6','K6'];
$objPHPExcel->getActiveSheet()->setCellValue('A1', $res['fcollname']);
$objPHPExcel->getActiveSheet()->setCellValue('A2', "PROVISIONAL RESULT SHEET"."-". $obj['fresexamdate']."EXAMINATION");
$objPHPExcel->getActiveSheet()->setCellValue('A3', $obj['fexamname']."-". $obj['fdescpn']."[". $degree."]");
$objPHPExcel->getActiveSheet()->setCellValue('A4',"Section".":".$section);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$alphgabets = ['C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N','O','Q','R','S','T','U','V','W','X'];
foreach($results2 as $key => $value){
foreach($results as $v){
$slNo = $key + 7;
$objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 6)->getColumnDimension('A')->setwidth(6);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fregno'])->getColumnDimension('B')->setwidth(20);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fname'])->getColumnDimension('C')->setwidth(35);
if($value['fgender']=="Male"){
$gender="M";
}else if($value['fgender']=="Female"){
$gender="F";
}else{
$gender="Other";
}
$objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $gender)->getColumnDimension('D')->setwidth(6);
$objPHPExcel->getActiveSheet()->setCellValue($subArr[$j].$slNo, $value["FSGPA"])->getColumnDimension('D')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue($subArr[$j+1].$slNo, $value["FCGPA"])->getColumnDimension('D')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue($subArr[$j+2].$slNo, $value["FCLASS"])->getColumnDimension('D')->setwidth(20);
$submarks=explode("|",$value['subdet']);
$l=0;
foreach($submarks as $val){
$explode = explode("*", $val);
if($v['fsubshort'] == $explode[0]){
$objPHPExcel->getActiveSheet()->setCellValue($arrSE[$l] . $slNo, $explode[1])->getColumnDimension('B')->setwidth(20);
$objPHPExcel->getActiveSheet()->setCellValue($arrCI[$l] . $slNo, $explode[2])->getColumnDimension('B')->setwidth(20);
$objPHPExcel->getActiveSheet()->setCellValue($arrTT[$l] . $slNo, $explode[3])->getColumnDimension('B')->setwidth(20);
$objPHPExcel->getActiveSheet()->setCellValue($arrGR[$l] . $slNo, $explode[4])->getColumnDimension('B')->setwidth(20);
$objPHPExcel->getActiveSheet()->setCellValue($arrCP[$l] . $slNo, $explode[5])->getColumnDimension('B')->setwidth(20);
}
$l++;
}
$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo . ':'.$subArr[$j+1] . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo . ':'.$subArr[$j+1] . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.$subArr[$j+1].$slNo)->applyFromArray($styleArray);
}
}
getheaders($objPHPExcel, $fileName);
}
?>
|