コード例 #1
0
        $objPHPExcel->getActiveSheet()->getStyle(getLatter($x) . $j . ':' . getLatter($x) . $j)->applyFromArray($styleThinBlackBorderOutline);
        $x++;
    }
    $objPHPExcel->getActiveSheet()->getStyle('A' . $j . ':A' . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('B' . $j . ':B' . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
    $j++;
    $x = 0;
    $objPHPExcel->getActiveSheet()->getStyle('A' . $j . ':A' . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    for ($i = 0; $i < count($nr); $i++) {
        $objPHPExcel->getActiveSheet()->SetCellValue(getLatter($x) . $j, $nr[$i]);
        $objPHPExcel->getActiveSheet()->getStyle(getLatter($x) . $j . ':' . getLatter($x) . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
        $objPHPExcel->getActiveSheet()->getStyle(getLatter($x) . $j . ':' . getLatter($x) . $j)->applyFromArray($styleThinBlackBorderOutline);
        $x++;
    }
    $objPHPExcel->getActiveSheet()->getStyle('A' . $j . ':A' . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objPHPExcel->getActiveSheet()->getStyle('B' . $j . ':B' . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
    $objPHPExcel->getActiveSheet()->mergeCells('A2:' . getLatter($x - 1) . '2');
    $objPHPExcel->getActiveSheet()->mergeCells('A3:' . getLatter($x - 1) . '3');
    if (function_exists('date_default_timezone_set')) {
        date_default_timezone_set('UTC');
    } else {
        putenv("TZ=UTC");
    }
    $exportTime = date("Y-m-d_His", time());
    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
    $file = 'Stockout_Trend_' . $exportTime . '.xlsx';
    $objWriter->save(str_replace('.php', '.xlsx', 'media/' . $file));
    header('Location:media/' . $file);
} else {
    echo 'No record found';
}
コード例 #2
0
            }
            if ($l == 'A') {
                $objPHPExcel->getActiveSheet()->getStyle($l . $j . ':' . $l . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
            } else {
                if ($l == 'B') {
                    $objPHPExcel->getActiveSheet()->getStyle($l . $j . ':' . $l . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
                } else {
                    $objPHPExcel->getActiveSheet()->getStyle($l . $j . ':' . $l . $j)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
                }
            }
            $k++;
        }
        $j++;
    }
    $objPHPExcel->getActiveSheet()->mergeCells('A2:' . getLatter($k - 1) . '2');
    $objPHPExcel->getActiveSheet()->mergeCells('A3:' . getLatter($k - 1) . '3');
    $objPHPExcel->getActiveSheet()->mergeCells('A4:' . getLatter($k - 1) . '4');
    $objPHPExcel->getActiveSheet()->mergeCells('A5:' . getLatter($k - 1) . '5');
    if (function_exists('date_default_timezone_set')) {
        date_default_timezone_set('UTC');
    } else {
        putenv("TZ=UTC");
    }
    $exportTime = date("Y-m-d_His", time());
    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
    $file = 'Stock_Status_at_Different_Levels_' . $exportTime . '.xlsx';
    $objWriter->save(str_replace('.php', '.xlsx', 'media/' . $file));
    header('Location:media/' . $file);
} else {
    echo 'No record found .';
}