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.149.255.239
<?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 generesultsheet_excel($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"];
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$yearmode = explode("*",$yearmode);
$year = $yearmode[0];
$examtye = $yearmode[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);
if($funivcode=="055"){
$scpa="if(('{$funivcode}' = '041' || '{$funivcode}' = '042'),r.FPREVTOT, IF(r.fcgpa = 0.00, '-', r.fcgpa)) AS fcgpa,";
}else{
$scpa="if(('{$funivcode}' = '041' || '{$funivcode}' = '042'),r.FPREVTOT, r.fcgpa) as fcgpa,";
}
$lobj_fee_data = "select distinct r.fregno, s.fname, r.fdegree, r.ftotmarks,
r.fmaxmarks, if(r.fpercent = '',' - ',ifnull(r.fpercent,' - ')) as fpercent, fclass, FSCHEME, r.fmcnumber as remarks,
$scpa
if(('{$funivcode}' = '041' || '{$funivcode}' = '042'),r.FPERCENT, r.fsgpa) as fsgpa
from resmarks r inner join student s
on r.fdegree = s.fdegree and r.fregno = s.fregno
where s.fdegree = '{$degree}' and s.fcollcode = '{$collcode}'
and r.fexamno = '{$degexam}'
and r.fyear = '{$year}' and r.fexamtype = '{$examtye}'";
$result = $aobj_context->mobj_db->GetAll($lobj_fee_data);
// Example:
$objPHPExcel = new PHPExcel();
$fileName = 'results_sheet.xls';
// var_dump($subdet);die();
$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);
// Add column headers and make them bold
$styleArray = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('argb' => '000000'),
),
),
);
$count = "";
$alpha = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
$j=4;
// if($subdet == "CIE"){
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getRowDimension(3)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
$objPHPExcel->getActiveSheet()->freezePane('A1');
// $objPHPExcel->getActiveSheet()->freezePane('D1');
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl No.');
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'USN');
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'Student Name ');
$objPHPExcel->getActiveSheet()->setCellValue('D1', 'S.G.P.A');
$objPHPExcel->getActiveSheet()->setCellValue('E1', 'C.G.P.A');
$objPHPExcel->getActiveSheet()->setCellValue('F1', 'Remarks');
$objPHPExcel->getActiveSheet()->setCellValue('G1', 'Withheld Remarks');
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->applyFromArray($styleArray);
$slNo = 2;
foreach ($result as $key => $value) {
$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['fname'])->getColumnDimension('C')->setwidth(35);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo,$value['fsgpa'])->getColumnDimension('D3')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo,$value['fcgpa'])->getColumnDimension('D3')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo,$value['fclass'])->getColumnDimension('D3')->setwidth(10);
$objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo,$value['remarks'])->getColumnDimension('D3')->setwidth(10);
$slNo++;
}
getheaders($objPHPExcel, $fileName);
}
?>
|