67 lines
2.6 KiB
PHP
Executable File
67 lines
2.6 KiB
PHP
Executable File
<?php
|
||
$objPHPExcel = new \PHPExcel();
|
||
|
||
// Set document properties
|
||
$objPHPExcel->getProperties()->setCreator("Nabati")
|
||
->setLastModifiedBy("Nabati")
|
||
->setTitle("Office 2007 XLSX TEMPLATE UPLOAD ")
|
||
->setSubject("TEMPLATE UPLOAD ")
|
||
->setDescription("TEMPLATE UPLOAD ")
|
||
->setKeywords("office 2007 openxml php")
|
||
->setCategory("TEMPLATE UPLOAD ");
|
||
|
||
$cel = 1;
|
||
$condition = "new, second, scrap";
|
||
$objPHPExcel->setActiveSheetIndex(0)
|
||
->setCellValue('A1', 'No')
|
||
->setCellValue('B1', 'Department')
|
||
->setCellValue('C1', 'Business Unit')
|
||
->setCellValue('D1', 'Line')
|
||
->setCellValue('E1', 'Section')
|
||
->setCellValue('F1', 'Activities')
|
||
->setCellValue('G1', 'PIC')
|
||
->setCellValue('H1', 'Note')
|
||
->setCellValue('I1', 'Date Time')
|
||
->setCellValue('J1', 'Photo');
|
||
$row=2;
|
||
foreach ($list as $key => $value) {
|
||
$photoStr = "";
|
||
if (isset($value['photo']) && count($value['photo']) !== 0) {
|
||
foreach ($value['photo'] as $val) {
|
||
$photoStr .= $val['img'] .", ";
|
||
}
|
||
}
|
||
$objPHPExcel->setActiveSheetIndex(0)
|
||
->setCellValue('A'.($row+$key), ($key+1))
|
||
->setCellValue('B'.($row+$key), $value['department_name'])
|
||
->setCellValue('C'.($row+$key), $value['bu_name'])
|
||
->setCellValue('D'.($row+$key), $value['line_name'])
|
||
->setCellValue('E'.($row+$key), $value['section_name'])
|
||
->setCellValue('F'.($row+$key), $value['activities'])
|
||
->setCellValue('G'.($row+$key), $value['pic_name'])
|
||
->setCellValue('H'.($row+$key), $value['note'])
|
||
->setCellValue('I'.($row+$key), $value['date_time'])
|
||
->setCellValue('J'.($row+$key), $photoStr);
|
||
}
|
||
|
||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||
$objPHPExcel->setActiveSheetIndex(0);
|
||
|
||
// Redirect output to a client’s web browser (Excel2007)
|
||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||
header('Content-Disposition: attachment;filename="export-data-monitoring.xlsx"');
|
||
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
|
||
|
||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||
$objWriter->save('php://output');
|
||
$objPHPExcel->disconnectWorksheets();
|
||
unset($objPHPExcel);
|
||
exit; |