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 : 3.145.75.69
EXCEL REPORT FORMAT
<?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 marksEntryQnWiseNewReport($aobj_context)
{
session_start();
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$collcode=$_SESSION['collcode'];
$teachcode = $aobj_context->mobj_data["teachcode"];
$classid = $aobj_context->mobj_data["classid"];
$subject = $aobj_context->mobj_data["subcode"];
$txtmarks = $aobj_context->mobj_data["txtmarks"];
$testName = $aobj_context->mobj_data["testName"];
$sort = $aobj_context->mobj_data["fsort"];
$split = explode("*", $subject);
$subelement = $split[0];
$subdet = $split[1];
$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);
$page_header_university = "select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
FUNIVADD1 as 'state', pdf_logo_path,
ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control";
$lobj_page_header_university = $aobj_context->mobj_db->GetRow($page_header_university);
$get_coll_name = "select fcollname as FCOLLNAME, ftown as FTOWN from college
where fcollcode = '{$collcode}'";
$res_coll_name = $aobj_context->mobj_db->GetRow($get_coll_name);
$FUNIVNAME = $lobj_page_header_university['FUNIVNAME'];
$STATE = $lobj_page_header_university['state'];
$query="SELECT fclassname FROM attclass WHERE fclassid='{$classid}'";
$res_cls = $aobj_context->mobj_db->GetRow($query);
$query="SELECT DISTINCT fdegree FROM attendsum WHERE fteachcode='{$teachcode}' AND LEFT(fsubcode,4)=LEFT('$subelement',4) AND fclassid='{$classid}'";
$res_deg = $aobj_context->mobj_db->GetRow($query);
$query="SELECT fsubname FROM subject WHERE LEFT(fcsubcode, 5)=LEFT('{$subelement}', 5) AND fdegree='{$res_deg['fdegree']}'" ;
$res_sub = $aobj_context->mobj_db->GetRow($query);
$objPHPExcel = new PHPExcel();
$fileName = 'Qn_Wise_Marks_Report.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:6')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(18);
$objPHPExcel->getActiveSheet()->getStyle('2:2')->getFont()->setSize(18);
$objPHPExcel->getActiveSheet()->getStyle('3:3')->getFont()->setSize(14);
$objPHPExcel->getActiveSheet()->getStyle('4:4')->getFont()->setSize(13);
$alpha = [ 'D', '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','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW','BX','BY','BZ',
'CA','CB','CC','CD','CE','CF','CG','CH','CI','CJ','CK','CL','CM','CN','CO','CP','CQ','CR','CS','CT','CU','CV','CW','CX','CY','CZ'];
$objPHPExcel->getActiveSheet()->setCellValue('A1'," ". $lobj_page_header_university['FUNIVNAME']);
$objPHPExcel->getActiveSheet()->setCellValue('A2'," College -".$res_coll_name['FCOLLNAME']." - ". $lobj_page_header_university['state']);
$objPHPExcel->getActiveSheet()->setCellValue('A3'," Degree -".$res_deg['fdegree']. " Class Name -".$res_cls['fclassname'] );
$objPHPExcel->getActiveSheet()->setCellValue('A4'," Subject -".$res_sub['fsubname']);
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'Sl. No.');
$objPHPExcel->getActiveSheet()->setCellValue('B5', 'USN');
$objPHPExcel->getActiveSheet()->setCellValue('C5', 'NAME');
$objPHPExcel->getActiveSheet()->mergeCells('A5:A6');
$objPHPExcel->getActiveSheet()->mergeCells('B5:B6');
$objPHPExcel->getActiveSheet()->mergeCells('C5:C6');
$query1 = "SELECT distinct fqn FROM maxmarksint WHERE fsubcode='{$subelement}' AND fclassid='{$classid}' AND ftestname='{$testName}'";
$result1 = $aobj_context->mobj_db->GetAll($query1);
$columns="";
$i=0;
$j=0;
foreach ($result1 as $val) {
$query2 = "SELECT ifnull(fqnno, '')as fqnno FROM maxmarksint WHERE fsubcode='{$subelement}' AND fqn='{$val['fqn']}' AND fclassid='{$classid}' AND ftestname='{$testName}'";
$result2 = $aobj_context->mobj_db->GetAll($query2);
$objPHPExcel->getActiveSheet()->mergeCells($alpha[$j].'5:'.$alpha[(count($result2) + $j) - 1].'5');
$objPHPExcel->getActiveSheet()->setCellValue($alpha[$j].'5', "Qn. No. - ". $val['fqn']);
$objPHPExcel->getActiveSheet()->getStyle($alpha[$j].'5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
foreach ($result2 as $v) {
$columns.= 'fmarks'.$v['fqnno'].',';
$objPHPExcel->getActiveSheet()->setCellValue($alpha[$j].'6', $v['fqnno']);
$objPHPExcel->getActiveSheet()->getStyle($alpha[$j].'6')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$j++;
}
$i++;
}
$objPHPExcel->getActiveSheet()->setCellValue($alpha[$j].'5', "Total Marks");
$objPHPExcel->getActiveSheet()->getStyle($alpha[$j].'5')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->mergeCells($alpha[$j].'5:'.$alpha[$j].'6');
$query3="SELECT stu.FREGNO, stu.FNAME, sd.fexamno, sd.fdegree, stu.fcollcode,
IFNULL(ftotal, '')AS ftotal, IFNULL(facttotal, '')AS facttotal, $columns fu1max FROM attendsum a
INNER JOIN student stu ON stu.FREGNO=a.FREGNO AND stu.fdegree = a.fdegree
INNER JOIN degree d ON d.FDEGREE =a.FDEGREE AND d.Fexamno=a.Fexamno
INNER JOIN subdet sd ON a.fdegree = sd.fdegree AND a.fexamno = sd.fexamno
AND LEFT(a.fsubcode,4) = LEFT(sd.fcsubcode,4) LEFT JOIN marksint mak ON a.fdegree = mak.fdegree
AND a.FREGNO=mak.FREGNO AND mak.ftest = '{$testName}' AND mak.fsubcode='{$subelement}' WHERE a.fteachcode = '{$teachcode}'
AND a.fclassid = '{$classid}' AND a.FCOLLCODE='{$collcode}' AND LEFT(a.fsubcode,4) = LEFT('{$subelement}',4) GROUP BY fregno ORDER BY fname";
// var_dump($query3);die();
$result3 = $aobj_context->mobj_db->GetAll($query3);
$split=explode(",",$columns);
for($z = 0; $z < count($split); $z++) {
foreach ($result3 as $key => $value){
$slNo = $key + 7;
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $slNo - 6)->getColumnDimension('A')->setwidth(8);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $value['FREGNO'])->getColumnDimension('B')->setwidth(15);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$slNo, $value['FNAME'])->getColumnDimension('C')->setwidth(35);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('B'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$absTot = $value['ftotal'] == "-2" ? "Absent" : $value['ftotal'];
if($value[$split[$z]]== -1){
$con="";
} else if($absTot == "Absent"){
$con="Ab";
}else{
$con=$value[$split[$z]];
}
$arr=['D', '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','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW','BX','BY','BZ',
'CA','CB','CC','CD','CE','CF','CG','CH','CI','CJ','CK','CL','CM','CN','CO','CP','CQ','CR','CS','CT','CU','CV','CW','CX','CY','CZ'];
for($a=0;$a<count($split);$a++){
$objPHPExcel->getActiveSheet() ->setCellValue($alpha[$z].$slNo, $con)->getColumnDimension($arr[$a])->setWidth(6);
}
$objPHPExcel->getActiveSheet() ->setCellValue($alpha[count($split)-1].$slNo, $absTot)->getColumnDimension($alpha[$z])->setWidth(15);
$objPHPExcel->getActiveSheet()->getStyle($alpha[$z].$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($alpha[count($split)-1].$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->mergeCells('A1:'.$alpha[count($split)-1].'1');
$objPHPExcel->getActiveSheet()->mergeCells('A2:'.$alpha[count($split)-1].'2');
$objPHPExcel->getActiveSheet()->mergeCells('A3:'.$alpha[count($split)-1].'3');
$objPHPExcel->getActiveSheet()->mergeCells('A4:'.$alpha[count($split)-1].'4');
}
}
$objPHPExcel->getActiveSheet()->getStyle('A:B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle($alpha[$j].'1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('A4')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$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);
getheaders($objPHPExcel, $fileName);
}
?>
|