''"; $sql = "select count(*) as cnt from {$g5['sms5_book_table']} where 1 $sql_bg $sql_hp order by bk_name"; $total = sql_fetch($sql); if (!$total['cnt']) alert_just('데이터가 없습니다.'); $qry = sql_query("select * from {$g5['sms5_book_table']} where 1 $sql_bg $sql_hp order by bk_name"); if(! function_exists('column_char')) { function column_char($i) { return chr( 65 + $i ); } } include_once(G5_LIB_PATH.'/PHPExcel.php'); $excel = new PHPExcel(); $headers = array('이름', '전화번호'); $widths = array(18, 25); $header_bgcolor = 'FFABCDEF'; $last_char = column_char(count($headers) - 1); $rows = array(); $col = 0; for($i=1; $res=sql_fetch_array($qry); $i++) { //$res = array_map('iconv_euckr', $res); $hp = get_hp($res['bk_hp'], $hyphen); if ($no_hp && $res['bk_hp'] != '' && !$hp) continue; $rows[] = array($res['bk_name'], ' '.$hp); } $data = array_merge(array($headers), $rows); $excel->setActiveSheetIndex(0)->getStyle( "A1:${last_char}1" )->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setARGB($header_bgcolor); $excel->setActiveSheetIndex(0)->getStyle( "A:$last_char" )->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER)->setWrapText(true); foreach($widths as $i => $w) $excel->setActiveSheetIndex(0)->getColumnDimension( column_char($i) )->setWidth($w); $excel->getActiveSheet()->fromArray($data,NULL,'A1'); $filename = "휴대폰번호목록-".date("ymd", time()).".xls"; if( is_ie() ) $filename = utf2euc($filename); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename); header("Cache-Control: max-age=0"); $writer = PHPExcel_IOFactory::createWriter($excel, 'Excel5'); $writer->save('php://output'); exit;