Time out error

  • diyath
  • Newbie
  • Newbie
  • diyath
  • Posts: 5

Post 3+ Months Ago

I try to create excel file using php but it work with small amount of data record But more than 400 record it not work. And it gives time out error. Please help me solve this. My code given below

Code: [ Select ]
<?php
session_start();

include_once 'classes/dbcnxn.php';
include_once 'classes/mysql.class.php';
include_once 'classes/fun_userentry.php';
require('gen_excel/Classes/PHPExcel.php');
require('gen_excel/Classes/PHPExcel/IOFactory.php');

if(!logged_in() || ($_SESSION['user_type']!=ADMIN && $_SESSION['user_type']!=DATA_ENTRY))
{
    include_once 'admin_unauthorized.php';
    exit();
}

$objPHPExcel = new PHPExcel();
$db = new MySQLDrives($db_info);

$timezone = new DateTimeZone( "Asia/Colombo" );
$date = new DateTime();
$date->setTimezone( $timezone );

$srch = array('slctyard'=>'', 'scltshpngline'=>'');

if(isset($_REQUEST['slctyard'])){$srch['slctyard'] = $_REQUEST['slctyard'];}
if(isset($_REQUEST['scltshpngline'])){$srch['scltshpngline'] = $_REQUEST['scltshpngline'];}

    $srch_sql     =     'SELECT cnt.* , cntmv.yard_code,cntmv.movement_date, cntmv.vessel, cntmv.vessel_date, DATEDIFF(CURRENT_DATE(),cntmv.movement_date) as strday
FROM
t01_00container_movemant cntmv, m01_00container cnt,
(select MAX(movemant_id) as movemant_id , container_no from m02_00movement_details group by container_no) cntmndtl

WHERE
cntmndtl.container_no = cnt.container_no AND cntmndtl.movemant_id=cntmv.movemant_id
                        AND cnt.status != "N"';
$cnxn = ' AND ';
if($srch['slctyard']!='')
{
    $srch_sql .= $cnxn.' cntmv.yard_code = "'.$srch['slctyard'].'"';
    $cnxn = ' AND ';
}
if($srch['scltshpngline']!='')
{
    $srch_sql .= $cnxn.' cntmv.shippinng_line = "'.$srch['scltshpngline'].'"';
}
$srch_sql .= ' ORDER BY cntmv.yard_code, cntmv.shippinng_line';


$qry_id = $db->query($srch_sql);

/*$rwtype = $db->fetch_all_array("SELECT code FROM m05_00container_type");
foreach($rwtype as $typekey => $typeval)
    {$type[] = $typeval['code'];}
*/    //print_r($type);

/*$rwshpln = $db->fetch_all_array("SELECT contact_id FROM m03_00contacts");
foreach($rwshpln as $shplnkey => $shplnval)
    {$shpln[] = $shplnval['contact_id'];}
*/    //print_r($shpln);

//-------- Start of the Stock Summary-----------------

//$objPHPExcel->getActiveSheet()
//->setTitle(' Stock Report')
//print $srch_sql;
$objWorksheet1 = $objPHPExcel->createSheet(1);
$objWorksheet1->setTitle('Stock Report');

$objPHPExcel->setActiveSheetIndex(1);

//--Start Styles for
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
$objPHPExcel->getDefaultStyle()->getFont()->setSize(8);
$objPHPExcel->getDefaultStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFFFFFF');

$objPHPExcel->getActiveSheet()
->getStyle('C1:F1s')
->getFont()
->setBold(true)
->setSize(13);

$objPHPExcel->getActiveSheet()
->getStyle('B3:M3')
->getFont()
->setBold(true)
->setSize(9);

$objPHPExcel->getActiveSheet()
->getStyle('B5:K5')
->getFont()
->setBold(true)
->setSize(9);

$styleArray = array(
    'borders' => array(
        'outline' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN,
            'color' => array('argb' => 'FF000000'),
        ),
    ),
);

//--End Styles


$objPHPExcel->getActiveSheet()
->mergeCells('C1:F1')
->setCellValue('C1', 'SEACON CONTAINERS (PVT) LTD')

->mergeCells('B3:C3')
->setCellValue('B3', 'Date : '.$date->format( 'Y-m-d'))

->mergeCells('J3:K3')
->setCellValue('J3', 'Time : '.$date->format( 'h:i:s A'));

$heding = array('Yard Code', 'Shipping Line', 'Container Number', 'Container Type','In Date','Ex Vessel','Ex.Vs. Date', 'Status', 'Grade','Days Stored');
$col = 1; $row = 5;

$objPHPExcel->getActiveSheet()->getStyle('B5:K5')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);

foreach($heding as $hdval)
{
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $hdval);
    $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true);
    $col++;
}
$objPHPExcel->getActiveSheet()->getStyle('B'.$row.':K'.$row)->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$row++;

if($db->affected_rows>0)
{
    $pre_yard_code = '';
    
    while($rwsrch = mysql_fetch_array($qry_id))
    {
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $row, strtoupper($rwsrch['yard_code']));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $row, strtoupper($db->get_name_byid($rwsrch['contact_id'], 'contact_id','', '', 'company_name', 'm03_00contacts')));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $row, strtoupper($rwsrch['container_no']));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $row, strtoupper($rwsrch['type']));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $row, strtoupper($rwsrch['movement_date']));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $row, strtoupper($db->get_name_byid($rwsrch['vessel'], 'vessel_id', '', '', 'name', 'm06_00vessel')));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $row, strtoupper($rwsrch['vessel_date']));
        if($rwsrch['status']=='A'){$status = 'Available';}
        if($rwsrch['status']=='B'){$status = 'Block';}
        if($rwsrch['status']=='R'){$status = 'Reserved';}
        if($rwsrch['status']=='D'){$status = 'Damaged';}
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $row, strtoupper($status));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(9, $row, strtoupper($rwsrch['grade']));
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(10, $row, strtoupper($rwsrch['strday']));
        
        //This array is use for count number of status in each shipping line belongs to yards.
        $sts[$rwsrch['yard_code'].'+'.$rwsrch['contact_id'].'+'.$rwsrch['type']][$rwsrch['status']]++;
        //This array is use for count sub tatal of status in each shipping line belongs to yards.
        $subtot[$rwsrch['yard_code'].'+'.$rwsrch['contact_id']][$rwsrch['status']]++;
        //This array is use for count total of status .
        $grndtot[$rwsrch['status']]++;
        
        $objPHPExcel->getActiveSheet()->getStyle('B'.$row.':K'.$row)->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
        $row++;
    }
    $objPHPExcel->getActiveSheet()->getStyle('B'.$row.':K'.$row)->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
}
else
{
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $row, 'No Records Found.');
}

$objPHPExcel->getActiveSheet()
->getStyle('B5:K'.$row)->getFill()
->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
->getStartColor()->setARGB('00E8F3FF');

$objPHPExcel->getActiveSheet()->getStyle('B5:K'.$row)->applyFromArray($styleArray);

//-------- End of the Stock Report ------------------


//-------- Start of the Stock Summary-----------------

/*$objWorksheet1 = $objPHPExcel->createSheet(1);
$objWorksheet1->setTitle('Stock Summary');

$objPHPExcel->setActiveSheetIndex(1);
*/

$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setTitle('Stock Summary');

//--Start Styles for Declaration Report
$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
$objPHPExcel->getDefaultStyle()->getFont()->setSize(8);

$objPHPExcel->getActiveSheet()
->getStyle('C1:H1')
->getFont()
->setBold(true)
->setSize(13);

$objPHPExcel->getActiveSheet()
->getStyle('B2:G2')
->getFont()
->setBold(true)
->setSize(9);

$styleArray = array(
    'borders' => array(
        'outline' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN,
            'color' => array('argb' => 'FF000000'),
        ),
    ),
);

/*$objPHPExcel->getActiveSheet()
->getStyle('A1:Z500')->getFill()
->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
->getStartColor()->setARGB('FFFFFFFF');
*/
//--End Styles

$objPHPExcel->getActiveSheet()
->mergeCells('C1:H1')
->setCellValue('C1', 'SEACON CONTAINERS (PVT) LTD');


$objPHPExcel->getActiveSheet()
->mergeCells('B2:C2')
->setCellValue('B2', 'Date : '.$date->format( 'Y-m-d'))

->mergeCells('F2:G2')
->setCellValue('F2', 'Time : '.$date->format( 'h:i:s A'));

$pre_yard=''; $pre_shpln = ''; $pre_cntype = '';
$col = 1; $row = 4;
//print_r($subtot);
if(!empty($sts))
{
    foreach($sts as $stskey => $stscal)
    {
        //print "<br>".$stskey." => ".$stscal;
        //print_r($stscal);
        //print "<br /><br />";
        if($stscal['A']==''){$stscal['A']='0';}
        if($stscal['B']==''){$stscal['B']='0';}
        if($stscal['R']==''){$stscal['R']='0';}
        if($stscal['D']==''){$stscal['D']='0';}
        
        
        list($yard,$shpline,$cntype) = explode('+',$stskey);
        
        if($pre_yard=='')
        {
            $pre_yard = $yard;
            
            if($clr==0){$bgcolr='00E8F3FF';$clr++;}
            else{$clr=0;$bgcolr='FFFFFFFF';}
            
            $str_row = $row;
            
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Yard Code : ');
            $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($yard));
            $row++;
            
            $pre_shpln=$shpline;
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Shipping Line : ');
            $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
            $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true);
            $objPHPExcel->getActiveSheet()->mergeCells('C'.$row.':G'.$row.'');
            
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($db->get_name_byid($shpline, 'contact_id','', '', 'company_name', 'm03_00contacts')));
            $row+=2;
            
            $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'Type');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, 'Available');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, 'Block');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, 'Reserved');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, 'Damaged');
            $row++;
            
            $pre_cntype=$cntype;
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
            $row++;
        }
        elseif($pre_yard!=$yard)
        {
            $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'SUB TOTAL');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $subtot[$pre_yard.'+'.$pre_shpln]['A']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $subtot[$pre_yard.'+'.$pre_shpln]['B']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $subtot[$pre_yard.'+'.$pre_shpln]['R']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $subtot[$pre_yard.'+'.$pre_shpln]['D']);
            $row++;
            $end_row = $row;
            
            $objPHPExcel->getActiveSheet()->getStyle('B'.$str_row.':G'.$end_row)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($bgcolr);    
    
            $pre_yard = $yard;
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, '');
            $row++;
            
            if($clr==0){$bgcolr='00E8F3FF';$clr++;}
            else{$clr=0;$bgcolr='FFFFFFFF';}
            
            $str_row = $row;
            
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Yard Code : ');
            $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row,strtoupper( $yard));
            $row++;
            
            $pre_shpln=$shpline;
            $objPHPExcel->getActiveSheet()->mergeCells('C'.$row.':G'.$row.'');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Shipping Line : ');
            $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($db->get_name_byid($shpline, 'contact_id','', '', 'company_name', 'm03_00contacts')));
            $row+=2;
            
            $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'Type');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, 'Available');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, 'Block');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, 'Reserved');
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, 'Damaged');
            $row++;
            
            $pre_cntype=$cntype;
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
            $row++;
        }
        else
        {
            if($pre_shpln!=$shpline)
            {
            $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'SUB TOTAL');
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $subtot[$pre_yard.'+'.$pre_shpln]['A']);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $subtot[$pre_yard.'+'.$pre_shpln]['B']);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $subtot[$pre_yard.'+'.$pre_shpln]['R']);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $subtot[$pre_yard.'+'.$pre_shpln]['D']);
                $row++;
            
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, '');
                $row++;
                $end_row = $row;
            
                $objPHPExcel->getActiveSheet()->getStyle('B'.$str_row.':G'.$end_row)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($bgcolr);    
    
                $pre_shpln=$shpline;
                $objPHPExcel->getActiveSheet()->mergeCells('C'.$row.':G'.$row.'');
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Shipping Line : ');
            $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($db->get_name_byid($shpline, 'contact_id','', '', 'company_name', 'm03_00contacts')));
                $row+=2;
                
            $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'Type');
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, 'Available');
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, 'Block');
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, 'Reserved');
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, 'Damaged');
                $objPHPExcel->getActiveSheet()->getStyle($col, $row)->getFont()->setBold(true)->setSize(9);
                $row++;
                
                $pre_cntype=$cntype;
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
                $row++;
            }
            else
            {
                if($pre_cntype!=$cntype)
                {
                    $pre_cntype=$cntype;
                    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
                    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
                    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
                    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
                    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
                    $row++;
                }
            }
        }
    }
    
    $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'SUB TOTAL');
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $subtot[$pre_yard.'+'.$pre_shpln]['A']);
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $subtot[$pre_yard.'+'.$pre_shpln]['B']);
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $subtot[$pre_yard.'+'.$pre_shpln]['R']);
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $subtot[$pre_yard.'+'.$pre_shpln]['D']);
    $row+=2;
    $end_row = $row;
            
    $objPHPExcel->getActiveSheet()->getStyle('B'.$str_row.':G'.$end_row)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($bgcolr);    
    
    $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(9);
    
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'GRAND TOTAL');
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $grndtot['A']);
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $grndtot['B']);
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $grndtot['R']);
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $grndtot['D']);
    $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+1)->setAutoSize(true);
}

$objPHPExcel->getActiveSheet()->getStyle('before:G'.$row)->applyFromArray($styleArray);

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="stock_report.xls"');
header('Cache-Control: max-age=0');

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
?>
  1. <?php
  2. session_start();
  3. include_once 'classes/dbcnxn.php';
  4. include_once 'classes/mysql.class.php';
  5. include_once 'classes/fun_userentry.php';
  6. require('gen_excel/Classes/PHPExcel.php');
  7. require('gen_excel/Classes/PHPExcel/IOFactory.php');
  8. if(!logged_in() || ($_SESSION['user_type']!=ADMIN && $_SESSION['user_type']!=DATA_ENTRY))
  9. {
  10.     include_once 'admin_unauthorized.php';
  11.     exit();
  12. }
  13. $objPHPExcel = new PHPExcel();
  14. $db = new MySQLDrives($db_info);
  15. $timezone = new DateTimeZone( "Asia/Colombo" );
  16. $date = new DateTime();
  17. $date->setTimezone( $timezone );
  18. $srch = array('slctyard'=>'', 'scltshpngline'=>'');
  19. if(isset($_REQUEST['slctyard'])){$srch['slctyard'] = $_REQUEST['slctyard'];}
  20. if(isset($_REQUEST['scltshpngline'])){$srch['scltshpngline'] = $_REQUEST['scltshpngline'];}
  21.     $srch_sql     =     'SELECT cnt.* , cntmv.yard_code,cntmv.movement_date, cntmv.vessel, cntmv.vessel_date, DATEDIFF(CURRENT_DATE(),cntmv.movement_date) as strday
  22. FROM
  23. t01_00container_movemant cntmv, m01_00container cnt,
  24. (select MAX(movemant_id) as movemant_id , container_no from m02_00movement_details group by container_no) cntmndtl
  25. WHERE
  26. cntmndtl.container_no = cnt.container_no AND cntmndtl.movemant_id=cntmv.movemant_id
  27.                         AND cnt.status != "N"';
  28. $cnxn = ' AND ';
  29. if($srch['slctyard']!='')
  30. {
  31.     $srch_sql .= $cnxn.' cntmv.yard_code = "'.$srch['slctyard'].'"';
  32.     $cnxn = ' AND ';
  33. }
  34. if($srch['scltshpngline']!='')
  35. {
  36.     $srch_sql .= $cnxn.' cntmv.shippinng_line = "'.$srch['scltshpngline'].'"';
  37. }
  38. $srch_sql .= ' ORDER BY cntmv.yard_code, cntmv.shippinng_line';
  39. $qry_id = $db->query($srch_sql);
  40. /*$rwtype = $db->fetch_all_array("SELECT code FROM m05_00container_type");
  41. foreach($rwtype as $typekey => $typeval)
  42.     {$type[] = $typeval['code'];}
  43. */    //print_r($type);
  44. /*$rwshpln = $db->fetch_all_array("SELECT contact_id FROM m03_00contacts");
  45. foreach($rwshpln as $shplnkey => $shplnval)
  46.     {$shpln[] = $shplnval['contact_id'];}
  47. */    //print_r($shpln);
  48. //-------- Start of the Stock Summary-----------------
  49. //$objPHPExcel->getActiveSheet()
  50. //->setTitle(' Stock Report')
  51. //print $srch_sql;
  52. $objWorksheet1 = $objPHPExcel->createSheet(1);
  53. $objWorksheet1->setTitle('Stock Report');
  54. $objPHPExcel->setActiveSheetIndex(1);
  55. //--Start Styles for
  56. $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
  57. $objPHPExcel->getDefaultStyle()->getFont()->setSize(8);
  58. $objPHPExcel->getDefaultStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB('FFFFFFFF');
  59. $objPHPExcel->getActiveSheet()
  60. ->getStyle('C1:F1s')
  61. ->getFont()
  62. ->setBold(true)
  63. ->setSize(13);
  64. $objPHPExcel->getActiveSheet()
  65. ->getStyle('B3:M3')
  66. ->getFont()
  67. ->setBold(true)
  68. ->setSize(9);
  69. $objPHPExcel->getActiveSheet()
  70. ->getStyle('B5:K5')
  71. ->getFont()
  72. ->setBold(true)
  73. ->setSize(9);
  74. $styleArray = array(
  75.     'borders' => array(
  76.         'outline' => array(
  77.             'style' => PHPExcel_Style_Border::BORDER_THIN,
  78.             'color' => array('argb' => 'FF000000'),
  79.         ),
  80.     ),
  81. );
  82. //--End Styles
  83. $objPHPExcel->getActiveSheet()
  84. ->mergeCells('C1:F1')
  85. ->setCellValue('C1', 'SEACON CONTAINERS (PVT) LTD')
  86. ->mergeCells('B3:C3')
  87. ->setCellValue('B3', 'Date : '.$date->format( 'Y-m-d'))
  88. ->mergeCells('J3:K3')
  89. ->setCellValue('J3', 'Time : '.$date->format( 'h:i:s A'));
  90. $heding = array('Yard Code', 'Shipping Line', 'Container Number', 'Container Type','In Date','Ex Vessel','Ex.Vs. Date', 'Status', 'Grade','Days Stored');
  91. $col = 1; $row = 5;
  92. $objPHPExcel->getActiveSheet()->getStyle('B5:K5')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
  93. foreach($heding as $hdval)
  94. {
  95.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $hdval);
  96.     $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true);
  97.     $col++;
  98. }
  99. $objPHPExcel->getActiveSheet()->getStyle('B'.$row.':K'.$row)->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
  100. $row++;
  101. if($db->affected_rows>0)
  102. {
  103.     $pre_yard_code = '';
  104.     
  105.     while($rwsrch = mysql_fetch_array($qry_id))
  106.     {
  107.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $row, strtoupper($rwsrch['yard_code']));
  108.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, $row, strtoupper($db->get_name_byid($rwsrch['contact_id'], 'contact_id','', '', 'company_name', 'm03_00contacts')));
  109.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $row, strtoupper($rwsrch['container_no']));
  110.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $row, strtoupper($rwsrch['type']));
  111.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $row, strtoupper($rwsrch['movement_date']));
  112.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $row, strtoupper($db->get_name_byid($rwsrch['vessel'], 'vessel_id', '', '', 'name', 'm06_00vessel')));
  113.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $row, strtoupper($rwsrch['vessel_date']));
  114.         if($rwsrch['status']=='A'){$status = 'Available';}
  115.         if($rwsrch['status']=='B'){$status = 'Block';}
  116.         if($rwsrch['status']=='R'){$status = 'Reserved';}
  117.         if($rwsrch['status']=='D'){$status = 'Damaged';}
  118.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $row, strtoupper($status));
  119.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(9, $row, strtoupper($rwsrch['grade']));
  120.         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(10, $row, strtoupper($rwsrch['strday']));
  121.         
  122.         //This array is use for count number of status in each shipping line belongs to yards.
  123.         $sts[$rwsrch['yard_code'].'+'.$rwsrch['contact_id'].'+'.$rwsrch['type']][$rwsrch['status']]++;
  124.         //This array is use for count sub tatal of status in each shipping line belongs to yards.
  125.         $subtot[$rwsrch['yard_code'].'+'.$rwsrch['contact_id']][$rwsrch['status']]++;
  126.         //This array is use for count total of status .
  127.         $grndtot[$rwsrch['status']]++;
  128.         
  129.         $objPHPExcel->getActiveSheet()->getStyle('B'.$row.':K'.$row)->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
  130.         $row++;
  131.     }
  132.     $objPHPExcel->getActiveSheet()->getStyle('B'.$row.':K'.$row)->getBorders()->getVertical()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
  133. }
  134. else
  135. {
  136.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, $row, 'No Records Found.');
  137. }
  138. $objPHPExcel->getActiveSheet()
  139. ->getStyle('B5:K'.$row)->getFill()
  140. ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
  141. ->getStartColor()->setARGB('00E8F3FF');
  142. $objPHPExcel->getActiveSheet()->getStyle('B5:K'.$row)->applyFromArray($styleArray);
  143. //-------- End of the Stock Report ------------------
  144. //-------- Start of the Stock Summary-----------------
  145. /*$objWorksheet1 = $objPHPExcel->createSheet(1);
  146. $objWorksheet1->setTitle('Stock Summary');
  147. $objPHPExcel->setActiveSheetIndex(1);
  148. */
  149. $objPHPExcel->setActiveSheetIndex(0);
  150. $objPHPExcel->getActiveSheet()->setTitle('Stock Summary');
  151. //--Start Styles for Declaration Report
  152. $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
  153. $objPHPExcel->getDefaultStyle()->getFont()->setSize(8);
  154. $objPHPExcel->getActiveSheet()
  155. ->getStyle('C1:H1')
  156. ->getFont()
  157. ->setBold(true)
  158. ->setSize(13);
  159. $objPHPExcel->getActiveSheet()
  160. ->getStyle('B2:G2')
  161. ->getFont()
  162. ->setBold(true)
  163. ->setSize(9);
  164. $styleArray = array(
  165.     'borders' => array(
  166.         'outline' => array(
  167.             'style' => PHPExcel_Style_Border::BORDER_THIN,
  168.             'color' => array('argb' => 'FF000000'),
  169.         ),
  170.     ),
  171. );
  172. /*$objPHPExcel->getActiveSheet()
  173. ->getStyle('A1:Z500')->getFill()
  174. ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
  175. ->getStartColor()->setARGB('FFFFFFFF');
  176. */
  177. //--End Styles
  178. $objPHPExcel->getActiveSheet()
  179. ->mergeCells('C1:H1')
  180. ->setCellValue('C1', 'SEACON CONTAINERS (PVT) LTD');
  181. $objPHPExcel->getActiveSheet()
  182. ->mergeCells('B2:C2')
  183. ->setCellValue('B2', 'Date : '.$date->format( 'Y-m-d'))
  184. ->mergeCells('F2:G2')
  185. ->setCellValue('F2', 'Time : '.$date->format( 'h:i:s A'));
  186. $pre_yard=''; $pre_shpln = ''; $pre_cntype = '';
  187. $col = 1; $row = 4;
  188. //print_r($subtot);
  189. if(!empty($sts))
  190. {
  191.     foreach($sts as $stskey => $stscal)
  192.     {
  193.         //print "<br>".$stskey." => ".$stscal;
  194.         //print_r($stscal);
  195.         //print "<br /><br />";
  196.         if($stscal['A']==''){$stscal['A']='0';}
  197.         if($stscal['B']==''){$stscal['B']='0';}
  198.         if($stscal['R']==''){$stscal['R']='0';}
  199.         if($stscal['D']==''){$stscal['D']='0';}
  200.         
  201.         
  202.         list($yard,$shpline,$cntype) = explode('+',$stskey);
  203.         
  204.         if($pre_yard=='')
  205.         {
  206.             $pre_yard = $yard;
  207.             
  208.             if($clr==0){$bgcolr='00E8F3FF';$clr++;}
  209.             else{$clr=0;$bgcolr='FFFFFFFF';}
  210.             
  211.             $str_row = $row;
  212.             
  213.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Yard Code : ');
  214.             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
  215.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($yard));
  216.             $row++;
  217.             
  218.             $pre_shpln=$shpline;
  219.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Shipping Line : ');
  220.             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
  221.             $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true);
  222.             $objPHPExcel->getActiveSheet()->mergeCells('C'.$row.':G'.$row.'');
  223.             
  224.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($db->get_name_byid($shpline, 'contact_id','', '', 'company_name', 'm03_00contacts')));
  225.             $row+=2;
  226.             
  227.             $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
  228.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'Type');
  229.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, 'Available');
  230.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, 'Block');
  231.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, 'Reserved');
  232.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, 'Damaged');
  233.             $row++;
  234.             
  235.             $pre_cntype=$cntype;
  236.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
  237.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
  238.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
  239.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
  240.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
  241.             $row++;
  242.         }
  243.         elseif($pre_yard!=$yard)
  244.         {
  245.             $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
  246.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'SUB TOTAL');
  247.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $subtot[$pre_yard.'+'.$pre_shpln]['A']);
  248.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $subtot[$pre_yard.'+'.$pre_shpln]['B']);
  249.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $subtot[$pre_yard.'+'.$pre_shpln]['R']);
  250.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $subtot[$pre_yard.'+'.$pre_shpln]['D']);
  251.             $row++;
  252.             $end_row = $row;
  253.             
  254.             $objPHPExcel->getActiveSheet()->getStyle('B'.$str_row.':G'.$end_row)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($bgcolr);    
  255.     
  256.             $pre_yard = $yard;
  257.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, '');
  258.             $row++;
  259.             
  260.             if($clr==0){$bgcolr='00E8F3FF';$clr++;}
  261.             else{$clr=0;$bgcolr='FFFFFFFF';}
  262.             
  263.             $str_row = $row;
  264.             
  265.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Yard Code : ');
  266.             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
  267.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row,strtoupper( $yard));
  268.             $row++;
  269.             
  270.             $pre_shpln=$shpline;
  271.             $objPHPExcel->getActiveSheet()->mergeCells('C'.$row.':G'.$row.'');
  272.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Shipping Line : ');
  273.             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
  274.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($db->get_name_byid($shpline, 'contact_id','', '', 'company_name', 'm03_00contacts')));
  275.             $row+=2;
  276.             
  277.             $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
  278.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'Type');
  279.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, 'Available');
  280.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, 'Block');
  281.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, 'Reserved');
  282.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, 'Damaged');
  283.             $row++;
  284.             
  285.             $pre_cntype=$cntype;
  286.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
  287.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
  288.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
  289.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
  290.             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
  291.             $row++;
  292.         }
  293.         else
  294.         {
  295.             if($pre_shpln!=$shpline)
  296.             {
  297.             $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
  298.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'SUB TOTAL');
  299.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $subtot[$pre_yard.'+'.$pre_shpln]['A']);
  300.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $subtot[$pre_yard.'+'.$pre_shpln]['B']);
  301.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $subtot[$pre_yard.'+'.$pre_shpln]['R']);
  302.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $subtot[$pre_yard.'+'.$pre_shpln]['D']);
  303.                 $row++;
  304.             
  305.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, '');
  306.                 $row++;
  307.                 $end_row = $row;
  308.             
  309.                 $objPHPExcel->getActiveSheet()->getStyle('B'.$str_row.':G'.$end_row)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($bgcolr);    
  310.     
  311.                 $pre_shpln=$shpline;
  312.                 $objPHPExcel->getActiveSheet()->mergeCells('C'.$row.':G'.$row.'');
  313.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, 'Shipping Line : ');
  314.             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->getFont()->setBold(true)->setSize(9);
  315.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, strtoupper($db->get_name_byid($shpline, 'contact_id','', '', 'company_name', 'm03_00contacts')));
  316.                 $row+=2;
  317.                 
  318.             $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
  319.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'Type');
  320.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, 'Available');
  321.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, 'Block');
  322.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, 'Reserved');
  323.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, 'Damaged');
  324.                 $objPHPExcel->getActiveSheet()->getStyle($col, $row)->getFont()->setBold(true)->setSize(9);
  325.                 $row++;
  326.                 
  327.                 $pre_cntype=$cntype;
  328.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
  329.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
  330.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
  331.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
  332.                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
  333.                 $row++;
  334.             }
  335.             else
  336.             {
  337.                 if($pre_cntype!=$cntype)
  338.                 {
  339.                     $pre_cntype=$cntype;
  340.                     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, $cntype);
  341.                     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $stscal['A']);
  342.                     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $stscal['B']);
  343.                     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $stscal['R']);
  344.                     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $stscal['D']);
  345.                     $row++;
  346.                 }
  347.             }
  348.         }
  349.     }
  350.     
  351.     $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(8);
  352.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'SUB TOTAL');
  353.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $subtot[$pre_yard.'+'.$pre_shpln]['A']);
  354.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $subtot[$pre_yard.'+'.$pre_shpln]['B']);
  355.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $subtot[$pre_yard.'+'.$pre_shpln]['R']);
  356.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $subtot[$pre_yard.'+'.$pre_shpln]['D']);
  357.     $row+=2;
  358.     $end_row = $row;
  359.             
  360.     $objPHPExcel->getActiveSheet()->getStyle('B'.$str_row.':G'.$end_row)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($bgcolr);    
  361.     
  362.     $objPHPExcel->getActiveSheet()->getStyle('C'.$row.':G'.$row)->getFont()->setBold(true)->setSize(9);
  363.     
  364.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+1, $row, 'GRAND TOTAL');
  365.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+2, $row, $grndtot['A']);
  366.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+3, $row, $grndtot['B']);
  367.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+4, $row, $grndtot['R']);
  368.     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col+5, $row, $grndtot['D']);
  369.     $objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col+1)->setAutoSize(true);
  370. }
  371. $objPHPExcel->getActiveSheet()->getStyle('before:G'.$row)->applyFromArray($styleArray);
  372. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  373. header('Content-Disposition: attachment;filename="stock_report.xls"');
  374. header('Cache-Control: max-age=0');
  375. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
  376. $objWriter->save('php://output');
  377. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • dark_lord
  • Graduate
  • Graduate
  • User avatar
  • Posts: 162
  • Loc: India-Kolkata

Post 3+ Months Ago

well this is obviously not possible to check, what i believe is, since you are able to do with small data, the code is workable, what you can do is divide the big file into small parts and carry on the operation or increase the timeout seconds.
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

My only guess is your running into a memory limit or execution time problem.

Whats the most data you can do without it freezing on you and how long does it take?

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 93 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.