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 : 18.222.184.207
<?php
ini_set('max_execution_time', 60);
$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 collegeCateGenWiseReport($result, $aobj_context)
{
$objPHPExcel = new PHPExcel();
$fileName = 'CollegeCategoryGenderWiseReport';
$objPHPExcel->getProperties()->setCreator("Me")
->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);
$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'];
$deggrp = $aobj_context->mobj_data["dgp"] . ' - ' . $results['fexamdate'];
$objPHPExcel->getActiveSheet()->getHeaderFooter()
->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME . "\n" . '&12' .
' - ' . $deggrp);
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');
// Add column headers and make them bold
$styleArray = array(
'borders' => array(
'allborders' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('argb' => '000000'),
),
),
);
$cat = ['CAT-I', 'GM', 'IIA', 'IIB', 'IIIA', 'IIIB', 'SC', 'ST'];
$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'
];
$objPHPExcel->getActiveSheet()->getStyle('1:2')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:2')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->freezePane('D3');
$objPHPExcel->getActiveSheet()->mergeCells('A1:A2')->setCellValue('A1', 'Sl. No.');
$objPHPExcel->getActiveSheet()->mergeCells('B1:B2')
->setCellValue('B1', 'College Code');
$objPHPExcel->getActiveSheet()->mergeCells('C1:C2')
->setCellValue('C1', 'College Name');
$j = 3;
for($i = 0; $i < count($cat);$i++) {
$objPHPExcel->getActiveSheet()->mergeCells($alpha[$j].'1:'.$alpha[$j+2].'1')
->setCellValue($alpha[$j].'1', $cat[$i]);
$j += 3;
}
$objPHPExcel->getActiveSheet()->mergeCells($alpha[$j].'1:'.$alpha[$j+2].'1')
->setCellValue($alpha[$j].'1', "Total");
$j = 3;
for($i = 0; $i < count($cat);$i++) {
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$j].'2', "Male");
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$j+1].'2', "Female");
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$j+2].'2', "Total");
$j += 3;
}
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$j].'2', "Male");
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$j+1].'2', "Female");
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$j+2].'2', "Total");
// die();
$objPHPExcel->getActiveSheet()->getStyle('A1:AD2')->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(20);
$objPHPExcel->getActiveSheet()->getRowDimension('2')->setRowHeight(20);
$objPHPExcel->getActiveSheet()->getStyle('A1:AD2')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A1:AD2')->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:AD2')->getAlignment()
->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$j = 3;
$slNo = 1;
$sum = array();
foreach ($result as $key => $value) {
$objPHPExcel->getActiveSheet()->setCellValue('A' . $j, $slNo)
->getColumnDimension('A')->setwidth(5);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $j, $value['fcollcode'])
->getColumnDimension('B')->setwidth(10.43);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $j, $value['fcollname'])
->getColumnDimension('C')->setwidth(50);
$i = 3;
$mc = 0;
$fc = 0;
$tc = 0;
foreach($cat as $v) {
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i].$j, $value['M'.$v]);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+1].$j, $value['F'.$v]);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+2].$j, $value['F'.$v]+ $value['M'.$v]);
$mc += $value['M'.$v];
$fc += $value['F'.$v];
$tc += $value['F'.$v] + $value['M'.$v];
$sum['M'.$v] += $value['M'.$v];
$sum['F'.$v] += $value['F'.$v];
$sum['T'.$v] += $value['F'.$v] + $value['M'.$v];
$i += 3;
}
$objPHPExcel->getActiveSheet()->getStyle($alpha[$i].$j.':'.$alpha[$i+2].$j)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i].$j, $mc);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+1].$j, $fc);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+2].$j, $tc);
$objPHPExcel->getActiveSheet()->getRowDimension($j)->setRowHeight(26);
$j++;$slNo++;
}
$objPHPExcel->getActiveSheet()->getRowDimension($j)->setRowHeight(26);
$objPHPExcel->getActiveSheet()->getStyle($j)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->mergeCells('A'.$j.':C'.$j)
->setCellValue('A'.$j, "Total");
$i = 3;
$mc = 0;
$fc = 0;
$tc = 0;
foreach($cat as $v) {
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i].$j, $sum['M'.$v]);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+1].$j, $sum['F'.$v]);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+2].$j, $sum['F'.$v]+ $sum['M'.$v]);
$mc += $sum['M'.$v];
$fc += $sum['F'.$v];
$tc += $sum['F'.$v] + $sum['M'.$v];
$i += 3;
}
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i].$j, $mc);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+1].$j, $fc);
$objPHPExcel->getActiveSheet()
->setCellValue($alpha[$i+2].$j, $tc);
$objPHPExcel->getActiveSheet()->getStyle('A3' . ':AD' . $j)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyle('A3'.':AD' . $j)->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('C3'.':C' . $j)->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$objPHPExcel->getActiveSheet()->getStyle('A3' . ':AD' . $j)->getAlignment()
->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A3' . ':AD' . $j)->getAlignment()
->setWrapText(true);
getheaders($objPHPExcel, $fileName);
}
|