-=[ Mr. Bumblebee ]=-
_Indonesia_
<?php
if ( !isset($estimatecode)) exit ;
function f_mk_excel_colkey($n) {
$c = $n < 1 ? 0 : intval($n/26);
$k = chr($n-($c*26)+65);
if ( $c > 0 ) $k = f_mk_excel_colkey($c-1) . $k ;
return $k ;
}
//
$einfo['sumcost'] = 0 ;
$excelTbl_items = array();
$excelTbl_seq = 1 ;
foreach( $einfo['repeat-detail'] as $rs ) {
$excelTbl_items[] = array(
array( 'cols' => 3 , 'txt' => $rs['title'] ) , false , false , // title (colspan=3)
$rs['qry'] ,
array( 'txt' => $rs['cost'] , 'format' => 'money' ) ,
array( 'cols' => 2 , 'txt' => $rs['sum'] , 'format' => 'money' ) , false ,
'VATÆ÷ÇÔ'
);
$einfo['sumcost'] += $rs['sum'] ;
$excelTbl_seq++;
}
while ( $excelTbl_seq <= 20 ) {
$excelTbl_items[] = array(
array( 'cols' => 3 , 'txt' => '' ) , false , false , // title (colspan=3)
'' ,
array( 'txt' => '' , 'format' => 'money' ) ,
array( 'cols' => 2 , 'txt' => '' , 'format' => 'money' ) , false ,
''
);
$excelTbl_seq++;
}
$einfo['sumcost_kr'] = cost2kr($einfo['sumcost']);
//
$excelTbl = array();
$excelTbl[] = array( 28 , 4 , 6 , 16 , 16 , 6 , 8 , 16 ) ;
$excelTbl[] = array( array( 'cols' => 8 , 'txt' => $einfo['title'] ) , false , false , false , false , false , false , false );
$excelTbl[] = array( array( 'cols' => 2 , 'txt' => $einfo['wdate'] ) , false , array( 'rows' => 4 , 'txt' => "°ø\n±Þ\nÀÚ" ) , 'µî·Ï¹øÈ£' , array( 'cols' => 4 , 'txt' => '808-30-00231' , 'font' => 'bold' ) , false , false , false );
$excelTbl[] = array( array( 'cols' => 2 , 'txt' => $einfo['name'] ) , false , false , '»ó È£' , '½ÎÄ¿³Ý' , "¼º\n¸í" , array( 'cols' => 2 , 'txt' => '±èº¹¼ø' ) , false ) ;
$excelTbl[] = array( array( 'cols' => 2 , 'txt' => '±ÍÇÏ' ) , false , false , "»ç ¾÷ Àå\n¼Ò Àç Áö" , array( 'cols' => 4 , 'txt' => '¼¿ïƯº°½Ã Áß±¸ û±¸·Î113, »ê´Ùºôµù 201È£(½Å´çµ¿)' ) , false , false , false ) ;
$excelTbl[] = array( array( 'cols' => 2 , 'txt' => '¾Æ·¡¿Í °°ÀÌ °ßÀûÇÕ´Ï´Ù' ) , false , false , '¾÷ ÅÂ' , '¼Ò¸Å¾÷' , "Á¾\n¸ñ" , array( 'cols' => 2 , 'txt' => 'ÀüÀÚ»ó°Å·¡¾÷' ) , false ) ;
$excelTbl[] = array( "ÇÕ°è±Ý¾×\n(°ø±Þ°¡¾×+¼¼¾×)" , array( 'cols' => 4 , 'txt' => 'ÀÏ±Ý : ' . $einfo['sumcost_kr'] . 'Á¤' , 'font' => 'bold' ) , false , false , false , array( 'cols' => 3 , 'txt' => '(£Ü ' . number_format($einfo['sumcost']) . ')' , 'font' => 'bold' ) , false , false ) ;
$excelTbl[] = array( array( 'cols' => 3 , 'txt' => 'ǰ ¸í' , 'font' => 'bold' ) , false , false , array( 'txt' => '¼ö·®' , 'font' => 'bold' ) , array( 'txt' => '´Ü°¡' , 'font' => 'bold' ) , array( 'cols' => 2 , 'txt' => '±Ý¾×' , 'font' => 'bold' ) , false , array( 'txt' => 'ºñ°í' , 'font' => 'bold' ) ) ;
foreach( $excelTbl_items as $vs ) $excelTbl[] = $vs ;
$excelTbl[] = array( array( 'cols' => 3 , 'txt' => 'ÇÕ °è' , 'font' => 'bold' ) , false , false , '' , '' , array( 'cols' => 2 , 'txt' => $einfo['sumcost'] , 'format' => 'money' , 'font' => 'bold' ) , false , '' ) ;
//
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/excel/phpExcel_1_8/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$defaultBorderStyle = array( 'borders' => array(
'top' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN , 'color' => array( 'rgb' => '808080' ) ) ,
'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN , 'color' => array( 'rgb' => '808080' ) ) ,
'left' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array( 'rgb' => '808080' ) ),
'right' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array( 'rgb' => '808080' ) )
)) ;
foreach( $excelTbl as $key => $vals ) {
foreach( $vals as $x => $v ) {
$k = f_mk_excel_colkey($x) ;
if ( $key > 0 ) {
$line = $key ;
if ( $v === false ) continue ;
$pos = $k . $line ;
// set cell value
if ( is_array($v)) {
if ( !empty($v['cols']) || !empty($v['rows'])) {
$pos = $k . $line . ':' . f_mk_excel_colkey($x + ( !empty($v['cols']) ? $v['cols']-1 : 0 )) . ($line + ( !empty($v['rows']) ? $v['rows']-1 : 0)) ;
$objPHPExcel->setActiveSheetIndex(0)->mergeCells($pos)->setCellValue( $k . $line , iconv( 'EUC-KR' , 'UTF-8' ,$v['txt'])) ;
} else $objPHPExcel->setActiveSheetIndex(0)->setCellValue( $pos , iconv( 'EUC-KR' , 'UTF-8' ,$v['txt'])) ;
} else $objPHPExcel->setActiveSheetIndex(0)->setCellValue( $pos , iconv( 'EUC-KR' , 'UTF-8' ,$v)) ;
// default style
$objPHPExcel->getActiveSheet()->getStyle($pos)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle($pos)->applyFromArray( $defaultBorderStyle ) ;
$objPHPExcel->setActiveSheetIndex(0)->getStyle($pos)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
$objPHPExcel->setActiveSheetIndex(0)->getStyle($pos)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
if ( $v['format'] == 'number' ) $objPHPExcel->getActiveSheet()->getStyle($pos)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER);
if ( $v['format'] == 'money' ) $objPHPExcel->getActiveSheet()->getStyle($pos)->getNumberFormat()->setFormatCode('#,##0');
if ( $v['font'] == 'bold' ) $objPHPExcel->getActiveSheet()->getStyle($pos)->getFont()->setBold(true);
} else {
$objPHPExcel->getActiveSheet()->getColumnDimension($k)->setWidth($v);
}
}
}
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('sign');
$objDrawing->setPath('../product/img/soccernet_bill_sign.png');
$objDrawing->setCoordinates('H2');
$objDrawing->setOffsetX(60);
$objDrawing->setOffsetY(0);
$objDrawing->setResizeProportional(false);
$objDrawing->setWidth(40);
$objDrawing->setHeight(40);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
//$objPHPExcel->getActiveSheet()->getDefaultRowDimension() ->setRowHeight(20);
// loop end
$filename = $einfo['title'] . '_' . $einfo['name'] ;
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="' . $filename . '.xls"');
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit ;
?>
Copyright © 2017 || Recoded By Mr.Bumblebee