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.237.229
<?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);
ini_set('max_execution_time', 300);
ini_set('memory_limit', '512M');
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 . '.CSV"');
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, 'CSV');
$objWriter->save('php://output');
}
function revaQpindentCsv($aobj_context)
{
$objPHPExcel = new PHPExcel();
$univcode = $aobj_context->mobj_data["univcode"];
$fileName = 'Question_Paper_Count_Report';
$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);
$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()
->setCellValue('A1', 'Exam Date')
->setCellValue('B1', 'Session Type')
->setCellValue('C1', 'Session From')
->setCellValue('D1', 'Session To')
->setCellValue('E1', 'School Code')
->setCellValue('F1', 'School Name')
->setCellValue('G1', 'Program Code')
->setCellValue('H1', 'Program Name')
->setCellValue('I1', 'Exam No')
->setCellValue('J1', 'Subject Code')
->setCellValue('K1', 'Qpcode')
->setCellValue('L1', 'Course Name')
->setCellValue('M1', 'Course Code')
->setCellValue('N1', 'Subject Type')
->setCellValue('O1', 'Examination Type')
->setCellValue('P1', 'COUNT');
$j = 3;
$slNo = 1;
$sum = array();
$fdeggrp = $aobj_context->mobj_data["deggrp"];
$fdatefrom = $aobj_context->mobj_data["fdatefrom"];
$fdateto = $aobj_context->mobj_data["fdateto"];
$fyear = $aobj_context->mobj_data["fyear"];
$fexamtype = $aobj_context->mobj_data["fexamtype"];
// $fdeggrp = $aobj_context->mobj_data["fdeggrp"];
$query = "select m.fdate as fdate, t.fsessiont as fsession, TRIM(LEFT(r.fdescpn, INSTR(r.fdescpn,' to '))) AS ffrom,
TRIM(MID(r.fdescpn, INSTR(r.fdescpn,' to ')+4,100)) AS fto, cd.fcollcode as college, cl.fcollname as name,
cd.fdegree as degree, d.fdescpn as descp, s.fexamno as examno, s.fcsubcode as subcode, t.fqpcode as qpcode,
concat(s.fmarkdesc1,s.fmarkdesc2) as fsubname, s.fsubshort as short, s.fssubname as subtype,
(case when cd.forder='1' then 'TAB' else '' end) as examtype,
count(distinct cd.fregno) as count
from timetable t inner join masdate m on m.fdeggrp = t.fdeggrp
and m.fdatecode = t.fdatecodet
and m.fyear = t.fyear and m.fexamtype = t.fexamtype
inner join subject s on t.fqpcode = s.fqpcode
inner join canddet cd on s.fdegree = cd.fdegree
inner join degree d on d.fdegree=cd.fdegree and d.fexamno = cd.fexamno
and s.fexamno = cd.fexamno
and s.fsubcode = cd.fsubcode
inner join college cl on cd.fcollcode = cl.fcollcode
inner join reason r on r.freasoncd = t.fsessiont
where ifnull(cd.fpresent,'')='p' and ifnull(cd.fpassmth,'')=''
and t.fyear = '{$fyear}' and t.fexamtype ='{$fexamtype}'
and t.fdoe between date_format(str_to_date('{$fdatefrom}','%d/%m/%Y'),'%Y-%m-%d')
and date_format(str_to_date('{$fdateto}','%d/%m/%Y'),'%Y-%m-%d') and t.fdeggrp like '{$fdeggrp}'
and cd.fpresent = 'P'
group by m.fdate, t.fsessiont, r.fdescpn ,cd.fdegree,d.fdescpn,s.fexamno,s.fcsubcode,t.fqpcode";
// var_dump($query);
// die();
$result = $aobj_context->pobj_db->GetAll($query);
$i = 2;
$totamt=0;
foreach ($result as $key => $value) {
$objPHPExcel->getActiveSheet()
->setCellValue('A' . $i, $value["fdate"]);
$objPHPExcel->getActiveSheet()
->setCellValue('B' . $i, $value["fsession"]);
$objPHPExcel->getActiveSheet()
->setCellValue('C' . $i, $value["ffrom"]);
$objPHPExcel->getActiveSheet()
->setCellValue('D' . $i, $value["fto"]);
$objPHPExcel->getActiveSheet()
->setCellValue('E' . $i, $value["college"]);
$objPHPExcel->getActiveSheet()
->setCellValue('F' . $i, $value["name"]);
$objPHPExcel->getActiveSheet()
->setCellValue('G' . $i, $value["degree"]);
$objPHPExcel->getActiveSheet()
->setCellValue('H' . $i, $value["descp"]);
$objPHPExcel->getActiveSheet()
->setCellValue('I' . $i, $value['examno']);
$objPHPExcel->getActiveSheet()
->setCellValue('J' . $i, $value["subcode"]);
$objPHPExcel->getActiveSheet()
->setCellValue('K' . $i, $value["qpcode"]);
$objPHPExcel->getActiveSheet()
->setCellValue('L' . $i, $value["fsubname"]);
$objPHPExcel->getActiveSheet()
->setCellValue('M' . $i, $value["short"]);
$objPHPExcel->getActiveSheet()
->setCellValue('N' . $i, $value["subtype"]);
$objPHPExcel->getActiveSheet()
->setCellValue('O' . $i, $value["examtype"]);
$objPHPExcel->getActiveSheet()
->setCellValue('P' . $i, $value["count"]);
$i++;
}
getheaders($objPHPExcel, $fileName);
}
|