worknova.manus/export_excel_default.php
LAPTOP-V9RRD1TL\Michelle's Computer f8f8fcaf96 first commit
2025-07-21 21:38:17 +08:00

59 lines
1.8 KiB
PHP

<?php
include 'PhpExcel/PHPExcel.php' ;
$page_filename = $page_export_file_name.date( 'Ymd', time() ) ;
$objPHPExcel = new PHPExcel() ;
$objPHPExcel->getProperties()
->setCreator(COMPANY)
->setTitle(COMPANY)
->setSubject(COMPANY)
->setDescription(COMPANY)
->setKeywords(COMPANY)
->setCategory(COMPANY) ;
$objPHPExcel->getActiveSheet()->setTitle( $page_filename ) ;
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = PHPExcel_IOFactory::createWriter( $objPHPExcel, 'Excel5' ) ;
// default parameter
$count = 1 ;
$char = 'A' ;
if ($t_title_header_excel != '') {
$newChar = $char ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($newChar.$count, $t_title_header_excel);
$count ++ ;
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($newChar.$count, '');
$count ++;
}
$newChar = $char ;
foreach( $array_header_excel as $k => $v ){
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $newChar.$count, $v ) ;
$newChar++ ;
}
$count++ ;
$redeem_q = $mysqli->query( $mysqli_query ) ;
if (!empty($array_body_excel)){
foreach( $array_body_excel as $kk => $vv ){
$newChar = $char ;
foreach( $vv as $kkk => $vvv ){
$objPHPExcel->setActiveSheetIndex(0)->setCellValue( $newChar.$count, $vvv ) ;
$newChar++ ;
}
$count++ ;
}
}
header( 'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8' ) ;
header( 'Content-Disposition: attachment;filename="'.$page_filename.'.xls"' ) ;
header( 'Cache-Control: max-age=0' ) ;
// save to pc
ob_clean();
$objWriter->save('php://output') ;
header( "Refresh: 0" ) ;
exit ;
?>