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.119.19.206
<?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');
// 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
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 genrateOrderReportExcel($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$frmdate = $aobj_context->mobj_data["vdatefrom"];
$todate = $aobj_context->mobj_data["vdateto"];
$query = "select fexamid as ID, ftype as type, concat(fteachcode, ' - ', fname) as teach,
fexam, concat(eo.fcollcode,' - ', cl.fcollname) as college,fdate from examorder eo
inner join college cl on eo.fcollcode = cl.fcollcode where left(fdate,10)
between date_format(str_to_date('{$frmdate}','%d/%m/%Y'),'%Y-%m-%d')
and date_format(str_to_date('{$todate}','%d/%m/%Y'),'%Y-%m-%d')";
$result = $aobj_context->pobj_db->GetAll($query);
$objPHPExcel = new PHPExcel();
$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'];
$j=4;
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('1:1')->getFont()->setSize(12);
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFill()->getStartColor()->setRGB('000000');
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE));
$objPHPExcel->getActiveSheet()->getColumnDimension('A1')->setwidth(30);
// $objPHPExcel->getActiveSheet()->freezePane('A2');
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Sl. No.')
->setCellValue('B1', 'Order I.D')
->setCellValue('C1', 'Order Type')
->setCellValue('D1', 'School Code')
->setCellValue('E1', 'Examination Month')
->setCellValue('F1', 'Faculty Name')
->setCellValue('G1', 'Sent Date');
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->applyFromArray($styleArray);
// $objPHPExcel->getActiveSheet()->getStyle('A1:G1')->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getColumnDimension('1')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(30);
//$objPHPExcel->getActiveSheet()->getStyle('A1:AI1')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFill()->getStartColor()->setRGB('000000');
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getFont()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE));
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A1:G1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$count=rtrim($count,", ");
foreach ($result as $key => $value) {
$slNo = $key + 2;
$objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(25);
$objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(8);
$objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['ID'])->getColumnDimension('B')->setwidth(12);
$objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['type'])->getColumnDimension('C')->setwidth(18);
$objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['college'])->getColumnDimension('D')->setwidth(33);
$objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fexam'] )->getColumnDimension('E')->setwidth(21);
$objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['teach'])->getColumnDimension('F')->setwidth(35);
$objPHPExcel->getActiveSheet()->setCellValue('G' . $slNo, $value['fdate'])->getColumnDimension('G')->setwidth(20);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'C'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'C'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$slNo.':'.'E'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('E'.$slNo.':'.'E'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$slNo.':'.'I'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->getActiveSheet()->getStyle('G'.$slNo.':'.'I'.$slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::VERTICAL_CENTER);
// $objPHPExcel->getActiveSheet()->getStyle('A'.$slNo.':'.'G'.$slNo)->applyFromArray($styleArray);
}
$fileName = "OrderReportExcel.xls";
getheaders($objPHPExcel, $fileName);
}
?>
|