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 : 13.59.218.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', 600);
ini_set("memory_limit",'2048M');
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 studwiseFeeReport($aobj_context)
{
$objPHPExcel = new PHPExcel();
$fileName = 'StudentwiseFeeReport';
$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'),
),
),
);
$univcode = $aobj_context->mobj_data["univcode"];
$rformat = $aobj_context->mobj_data["Screentype"];
$fcollfrm = $aobj_context->mobj_data["cntr_from"];
$fcollto = $aobj_context->mobj_data["cntr_end"];
$fdegfrm = $aobj_context->mobj_data["degree_from"];
$fdegto = $aobj_context->mobj_data["degree_to"];
$exmrange = $aobj_context->mobj_data["examno_from"];
$deggrp = $aobj_context->mobj_data["Degree"];
$rtype = $aobj_context->mobj_data["ReportType"];
$rftype = $aobj_context->mobj_data["rftype"];
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->freezePane('A2');
$objPHPExcel->getActiveSheet()
->setCellValue('A1', 'Sl. No.')
->setCellValue('B1', 'College Code')
->setCellValue('C1', 'College Name')
->setCellValue('D1', 'Degree Code')
->setCellValue('E1', 'Reg. No.')
->setCellValue('F1', 'Student Name')
->setCellValue('G1', 'Categoty')
->setCellValue('H1', 'Consation')
->setCellValue('I1', 'Fee Head')
->setCellValue('J1', 'Amount')
;
$objPHPExcel->getActiveSheet()->getStyle('A1:J1')->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
$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);
$query = "select @a:=@a+1 serial_number, fcollcode, fcollname, fdegree, fregno, fname,
fcaste, fconstype, head, ftotalfee from
(select cs.fcollcode, concat(c.fcollname,', ',c.ftown) as fcollname, cs.fdegree,cs.fregno,
ucase(st.fname) as fname, st.fcaste, if(cs.fconstype='0123456789','NO','Yes') as fconstype,
group_concat(' ',sf.ffeecode,'(',sf.famount,')' order by ffeecode separator '
') as head, cs.ftotalfee
from candsum cs
left outer join studfee sf on sf.fcollcode=cs.fcollcode and sf.fdegree=cs.fdegree and
sf.fexamno=cs.fexamno and sf.fregno=cs.fregno
inner join college c on c.fcollcode=sf.fcollcode
inner join degree d on d.fdegree=sf.fdegree and d.fexamno=sf.fexamno
inner join student st on sf.fregno=st.fregno and sf.fdegree=st.fdegree
and sf.fcollcode=st.fcollcode
where sf.fcollcode between '{$fcollfrm}' and '{$fcollto}'
and sf.fdegree between '{$fdegfrm}' and '{$fdegto}'
and d.fdeggrp='{$deggrp}'
and ifnull(cs.frecptdate,'')<>'' and ifnull(cs.ftotalfee,'')<>''
group by sf.fregno
order by c.fcollcode,cs.fdegree) x, (SELECT @a:= 0) AS a";
$result = $aobj_context->pobj_db->GetAll($query);
$sheet = $objPHPExcel->getActiveSheet();
$sheet->fromArray(
$result, // The data to set
NULL, // Array values with this value will not be set
'A2' // Top left coordinate of the worksheet range where
// we want to set these values (default is A1)
);
$default_style = array(
'font' => array(
'name' => 'Verdana',
'color' => array('rgb' => '000000'),
'size' => 11
),
'alignment' => array(
'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER
),
'borders' => array(
'allborders' => array(
'style' => \PHPExcel_Style_Border::BORDER_THIN,
'color' => array('rgb' => 'AAAAAA')
)
)
);
// Apply default style to whole sheet
$sheet->getDefaultStyle()->applyFromArray($default_style);
$sheet->getColumnDimension('A')->setWidth(5);
$sheet->getColumnDimension('B')->setWidth(8.43);
$sheet->getColumnDimension('C')->setWidth(40);
$sheet->getColumnDimension('D')->setWidth(8.43);
$sheet->getColumnDimension('E')->setWidth(10);
$sheet->getColumnDimension('F')->setWidth(40);
$sheet->getColumnDimension('G')->setWidth(10);
$sheet->getColumnDimension('H')->setWidth(11);
$sheet->getColumnDimension('I')->setWidth(40);
$sheet->getColumnDimension('J')->setWidth(10);
// $objPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(15);
$sheet->getStyle('C1:C'.$sheet->getHighestRow())
->getAlignment()->setWrapText(true);
$sheet->getStyle('I1:I'.$sheet->getHighestRow())
->getAlignment()->setWrapText(true);
$lastrow = $sheet->getHighestRow();
$sheet->getStyle('I2:I'.$lastrow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$sheet->getStyle('C2:C'.$lastrow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$sheet->getStyle('F2:F'.$lastrow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$sheet->getStyle('F2:F'.$lastrow)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
$sheet->getStyle('A2:J'.$lastrow)->applyFromArray($styleArray);
// $styleArray ->applyFromArray($styleArray)
// foreach ($result as $key => $value) {
// $slNo = $key + 2;
// // echo($slNo);
// $sheet->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(5);
// $sheet->setCellValue('B' . $slNo, $value['fcollcode'])->getColumnDimension('B')->setwidth(8.43);
// $sheet->setCellValue('C' . $slNo, $value['fcollname'])->getColumnDimension('C')->setwidth(50);
// $sheet->setCellValue('D' . $slNo, $value['fdegree'])->getColumnDimension('D')->setwidth(8.43);
// $sheet->setCellValue('E' . $slNo, $value['fregno'])->getColumnDimension('E')->setwidth(10);
// $sheet->setCellValue('F' . $slNo, ucwords($value['fname']))->getColumnDimension('F')->setwidth(40);
// $sheet->setCellValue('G' . $slNo, $value['fcaste'])->getColumnDimension('G')->setwidth(10);
// $sheet->setCellValue('H' . $slNo, $value['fconstype'])->getColumnDimension('H')->setwidth(11);
// $sheet->setCellVAlue('I' . $slNo, $value['head'])->getColumnDimension('I')->setwidth(50);
// $sheet->setCellValue('J' . $slNo, moneyFormatIndia((int)$value['ftotalfee']))->getColumnDimension('J')->setwidth(10);
// // $sheet->setCellValue('I'.$slNo, $value['fdegree'])->getColumnDimension('I')->setwidth(45);
// // $sheet->getColumnDimension('D')->setwidth(12);
// $sheet->getStyle('A' . $slNo . ':J' . $slNo)->applyFromArray($styleArray);
// // $sheet->getRowDimension($slNo)->setRowHeight(33);
// $sheet->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
// $sheet->getStyle('A' . $slNo . ':B' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
// $sheet->getStyle('D' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
// $sheet->getStyle('D' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
// $sheet->getStyle('A' . $slNo . ':H' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
// $sheet->getStyle('A' . $slNo . ':H' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
// //->setWrapText(true);
// $sheet->getStyle('A' . $slNo . ':J' . $slNo)->getAlignment()->setWrapText(true);
// $sheet->getStyle('G' . $slNo .':H' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
// $sheet->getStyle('G' . $slNo .':H' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
// $sheet->getStyle('J' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
// $sheet->getStyle('J' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
// }
$sheet->setTitle($fileName);
$sheet->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);
$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'];
// $sheet->getHeaderFooter()->addImage($aobj_context->main_src.'img/'.$aobj_context->FUNIVCODE.'_logo.jpg', PHPExcel_Worksheet_HeaderFooter::IMAGE_HEADER_LEFT);
$sheet->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME . "\n" . '&12' . $rtype);
$sheet->getHeaderFooter()->setOddHeader('&C&H'.$rtype.' - '.$deggrp);
$sheet->getHeaderFooter()->setOddFooter('&RPage &P of &N');
getheaders($objPHPExcel, $fileName);
}
function moneyFormatIndia($num)
{
$explrestunits = "";
if (strlen($num) > 3) {
$lastthree = substr($num, strlen($num) - 3, strlen($num));
$restunits = substr($num, 0, strlen($num) - 3); // extracts the last three digits
$restunits = (strlen($restunits) % 2 == 1) ? "0" . $restunits : $restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
$expunit = str_split($restunits, 2);
for ($i = 0; $i < sizeof($expunit); $i++) {
// creates each of the 2's group and adds a comma to the end
if ($i == 0) {
$explrestunits .= (int)$expunit[$i] . ","; // if is first value , convert into integer
} else {
$explrestunits .= $expunit[$i] . ",";
}
}
$thecash = $explrestunits . $lastthree;
} else {
$thecash = $num;
}
return $thecash; // writes the final format where $currency is the currency symbol.
}
?>
|