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.15.3.153
<?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');
// 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
$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 ExamAppSumCourseWiseExcel($aobj_context)
{
$univcode = $aobj_context->mobj_data["univcode"];
$fdeggrp = $aobj_context->mobj_data["deggrp"];
$fdegfrom = $aobj_context->mobj_data["fdegfrom"];
$fdegto = $aobj_context->mobj_data["fdegto"];
$query = "select d.fdegree as Course, d.fdescpn as Description,
SUM(case when fappeara='A' and fexamfeea>0 then 1 else 0 end) as A,
SUM(case when fappearb='A' and fexamfeeb>0 then 1 else 0 end) as B,
SUM(case when fappearc='A' and fexamfeec>0 then 1 else 0 end) as C,
SUM(case when fappeard='A' and fexamfeed>0 then 1 else 0 end) as D,
SUM(case when fappeare='A' and fexamfeee>0 then 1 else 0 end) as E,
SUM(case when fappearf='A' and fexamfeef>0 then 1 else 0 end) as F,
SUM(case when fappeara='A' and fexamfeea>0 then 1 else 0 end) +
SUM(case when fappearb='A' and fexamfeeb>0 then 1 else 0 end) +
SUM(case when fappearc='A' and fexamfeec>0 then 1 else 0 end) +
SUM(case when fappeard='A' and fexamfeed>0 then 1 else 0 end) +
SUM(case when fappeare='A' and fexamfeee>0 then 1 else 0 end) +
SUM(case when fappearf='A' and fexamfeef>0 then 1 else 0 end) as Total
from candsum c, degree d
where d.fdeggrp='{$fdeggrp}' and d.fdegree between '{$fdegfrom}' and '{$fdegto}' and c.fdegree=d.fdegree
group by d.fdegree";
$result = $aobj_context->pobj_db->GetAll($query);
$objPHPExcel = new PHPExcel();
$fileName = 'ExamAppSumCourseWiseExcel';
$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'),
),
),
);
$count = "";
$alpha = ['A', 'B', 'C', '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', 'AF', 'AE', 'AF', 'AG', 'AH'
];
$j=4;
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->freezePane('A1');
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.')
->setCellValue('B1', 'Degree')
->setCellValue('C1', 'Description')
->setCellValue('D1', 'I Semester')
->setCellValue('E1', 'II Semester')
->setCellValue('F1', 'III Semester')
->setCellValue('G1', 'IV Semester')
->setCellValue('H1', 'V Semester')
->setCellValue('I1', 'VI Semester')
->setCellValue('J1', 'Total');
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getColumnDimension('I1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(29);
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$count=rtrim($count,", ");
foreach ($result as $key => $value) {
$slNo = $key + 2;
$j=4;
$objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(6.5);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['Course'])->getColumnDimension('B')->setwidth(8.43);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['Description'])->getColumnDimension('C')->setwidth(45);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['A'])->getColumnDimension('D')->setwidth(12);
$objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['B'])->getColumnDimension('E')->setwidth(12);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['C'])->getColumnDimension('F')->setwidth(12);
$objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['D'])->getColumnDimension('G')->setwidth(14);
$objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['E'])->getColumnDimension('H')->setwidth(12);
$objPHPExcel->getActiveSheet()->setCellValue('I' . $slNo, $value['F'])->getColumnDimension('I')->setwidth(14);
$objPHPExcel->getActiveSheet()->setCellValue('J' . $slNo, $value['Total'])->getColumnDimension('J')->setwidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setwidth(12);
$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':J'. $slNo)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_JUSTIFY);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_JUSTIFY);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo . ':E' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo . ':E' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E' . $slNo . ':J' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E' . $slNo . ':J' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
//$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
//$objPHPExcel->getActiveSheet()->getStyle('D' . $slNo)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('C' . $slNo)->getAlignment()->setWrapText(true);
}
$objPHPExcel->getActiveSheet()->setTitle($fileName);
$objPHPExcel->getActiveSheet()->getPageSetup()
->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$get_coll_name = "select FUNIVNAME as 'FUNIVNAME',FUNIVCODE,
FUNIVADD1 as 'state', pdf_logo_path,
ifnull(FEXAMAPPREQ,'F') as FEXAMAPPREQ From control";
$lobj_get_coll_name = $aobj_context->pobj_db->GetRow($get_coll_name);
// $deggrp = $aobj_context->mobj_data["dgp"];
// $query = "select distinct concat(fexamdate,' ',' Examination') as fexamdate
// from deggrp where fdeggrp = '{$deggrp}'";
// $results = $aobj_context->pobj_db->GetRow($query);
$aobj_context->FUNIVNAME = $lobj_get_coll_name['FUNIVNAME'];
$aobj_context->s_state = $lobj_get_coll_name['state'];
$aobj_context->pdf_logo_path = $lobj_get_coll_name['pdf_logo_path'];
$aobj_context->FUNIVCODE = $lobj_get_coll_name['FUNIVCODE'];
// die();
// $objPHPExcel->getActiveSheet()->getHeaderFooter()->addImage($aobj_context->main_src.'img/'.$aobj_context->FUNIVCODE.'_logo.jpg', PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME . "\n" . '&12' . $rtype);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$deggrp);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');
getheaders($objPHPExcel, $fileName);
}
?>
|