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.144.98.43
<?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');
/** 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);
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 getCopoMarksEntrySeeReport($aobj_context){
session_start();
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$valno = $aobj_context->mobj_data["valno"];
$packet = $aobj_context->mobj_data["packet"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$collcode=$_SESSION['collcode'];
$objPHPExcel = new PHPExcel();
$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'),
),
),
);
$qry3 = "select fdegree,fexamno from tdvs_qpcopo where fqpcode = '{$qpcode}'";
$res3 = $aobj_context->mobj_db->Getrow($qry3);
$degree = $res3['fdegree'];
$examno = $res3['fexamno'];
$query = "select p.fqncode,pd.fqnno,p.fmaxmarks
from tdvs_qpcopo p
inner join tdvs_qptempdetl_copo pd on p.ftempcode = pd.ftempcode
and p.fpartcode = pd.fpartcode and p.fqncode = pd.fqncode
where p.fdegree = '{$degree}' and p.fexamno = '{$examno}'
and ifnull(p.fmaxmarks,0) >0
and p.fqpcode = '{$qpcode}'
order by pd.fqncode";
$res=$aobj_context->mobj_db->GetAll($query);
$count = count($res);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
$objPHPExcel->getActiveSheet()->freezePane('A2');
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl No.');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Script No.');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Total Marks');
$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'];
$fileds = "";
$arry = [];
$qno = [];
for($i=0; $i<count($res); $i++){
$objPHPExcel->getActiveSheet()->setCellValue($arr[$i].'1', $res[$i]['fqnno']." ( ".$res[$i]['fmaxmarks']." )");
$fileds .= "ifnull(".'fq'.strtolower(str_replace(".","",$res[$i]['fqnno'])).",'-1') as ".'fq'.strtolower(str_replace(".","",$res[$i]['fqnno'])).", ";
$arry[$i] = 'fq'.strtolower(str_replace(".","",$res[$i]['fqnno']));
array_push($qno, $res[$i]['fqnno']);
}
$objPHPExcel->getActiveSheet()->getStyle('A1:'.$arr[$count - 1].'1')->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('A1:'.$arr[$count - 1].'1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:'.$arr[$count - 1].'1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$query = "select $fileds fregno,ftotmarks from tdvs_copomarks
where fcollcode = '{$packet}' and fvalno = '{$valno}'
and fsubcode = '{$qpcode}'";
$res2= $aobj_context->mobj_db->GetAll($query);
foreach ($res2 as $key => $value) {
$slNo = $key + 2;
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->setCellValue('A'.$slNo, $slNo - 1)->getColumnDimension('A')->setwidth(8);
$objPHPExcel->getActiveSheet()->setCellValue('B'.$slNo, $value['fregno'])->getColumnDimension('B')->setwidth(15);
$objPHPExcel->getActiveSheet()->setCellValue('C'.$slNo, $value['ftotmarks'])->getColumnDimension('C')->setwidth(15);
for($z =0;$z<count($arry);$z++){
$val = $value[$arry[$z]] == -1 ? "" : $value[$arry[$z]];
$objPHPExcel->getActiveSheet()->setCellValue($arr[$z].$slNo, $val)->getColumnDimension($arr[$z])->setwidth(10);
}
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.$arr[$count - 1].$slNo)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.$arr[$count - 1].$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.$arr[$count - 1].$slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
}
getheaders($objPHPExcel, 'copomarksentryexternal.xlsx');
}
?>
|