0xV3NOMx
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.133.149.244


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/Reports/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/Reports/Template_EXCEL.php

<?php
ini_set('max_execution_time', 300);
$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 writeReport($result, $aobj_context)
{

    $objPHPExcel = new PHPExcel();
    $fileName = 'CenterwiseIndent';

    // Set document properties
    $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);

    // Add column headers and make them bold
    $styleArray = array(
        'borders' => array(
            'allborders' => array(
                'style' => PHPExcel_Style_Border::BORDER_THIN,
                'color' => array('argb' => '000000'),
            ),
        ),
    );

    $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', 'QP Code')
        ->setCellValue('C1', 'Center Code')
        ->setCellValue('D1', 'Center Name')
        ->setCellValue('E1', 'Subject Name')
        ->setCellValue('F1', 'Date')
        ->setCellValue('G1', 'Session')
        ->setCellValue('H1', 'Qp Indent')
        // ->setCellValue('I1','Degree')
    ;
    $objPHPExcel->getActiveSheet()->getStyle('A1:H1')->applyFromArray($styleArray);
    // $objPHPExcel->getActiveSheet()->getColumnDimension('G1')->setAutoSize(true);
    $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(40);
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setWrapText(true);
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('A1:I1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    foreach ($result as $key => $value) {
        $slNo = $key + 2;

        $objPHPExcel->getActiveSheet()->setCellValue('A' . $slNo, $slNo - 1)->getColumnDimension('A')->setwidth(5);
        $objPHPExcel->getActiveSheet()->setCellValue('C' . $slNo, $value['fcntrcode'])->getColumnDimension('C')->setwidth(8.43);
        $objPHPExcel->getActiveSheet()->setCellValue('D' . $slNo, $value['fcntrname'])->getColumnDimension('D')->setwidth(50);
        $objPHPExcel->getActiveSheet()->setCellValue('B' . $slNo, $value['fqpcode'])->getColumnDimension('B')->setwidth(8.43);
        $objPHPExcel->getActiveSheet()->setCellValue('E' . $slNo, $value['fsubname'])->getColumnDimension('E')->setwidth(34);
        $objPHPExcel->getActiveSheet()->setCellValue('F' . $slNo, $value['fdoe'])->getColumnDimension('F')->setwidth(12.29);
        $objPHPExcel->getActiveSheet()->setCellVAlue('G' . $slNo, $value['fsession'])->getColumnDimension('G')->setwidth(20.29);
        $objPHPExcel->getActiveSheet()->setCellValue('H' . $slNo, $value['frounded'])->getColumnDimension('H')->setwidth(8);
        // $objPHPExcel->getActiveSheet()->setCellValue('I'.$slNo, $value['fdegree'])->getColumnDimension('I')->setwidth(45);

        // $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setwidth(12);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':H' . $slNo)->applyFromArray($styleArray);
        $objPHPExcel->getActiveSheet()->getRowDimension($slNo)->setRowHeight(33);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':C' . $slNo)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':C' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':I' . $slNo)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
        $objPHPExcel->getActiveSheet()->getStyle('A' . $slNo . ':I' . $slNo)->getAlignment()->setWrapText(true);
    }

    // Set worksheet title
    $objPHPExcel->getActiveSheet()->setTitle($fileName);
    $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
    // $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
    $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']; 

    $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'];

    $reportType = $aobj_context->mobj_data["rt"];


    // 
    $reportType = $aobj_context->mobj_data["rt"];

    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H&"-,Bold"&16' . $aobj_context->FUNIVNAME . "\n" . '&12' . $reportType . ' - ' . $deggrp);
    // $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&C&H'.$reportType.' - '.$deggrp);

    $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&RPage &P of &N');

    getheaders($objPHPExcel, $fileName);
}

function ReportFunction($aobj_context)
{
    $univcode = $aobj_context->mobj_data["univcode"];  

    $query = "SELECT * from student limit 10";
    $result = $aobj_context->pobj_db->GetAll($query);

    $class_obj = new ReprtObject();
    $class_obj->univcode = $univcode;
    $class_obj->DefaultConstructor($aobj_context);

    // If No data found Generate Blank Report
    if (count($result) > 0) {
        $class_obj->cwwriteReport($result);
    }

    $class_obj->SendOutput();

}