1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
<?php $dir = "."; include_once($dir."/_common.php");
if($eid==''){ alert('e천년경영 로그인 후에 이용가능합니다.',"index.php"); exit; }
$where = " "; if($biztype=='' || $biztype=='1'){ $where .= " and biztype = '1' "; $biztype_misu = "현재 미수금"; $biztype=='1'; } else if($biztype=='0'){ $where .= " and biztype = '0' "; $biztype_misu = "현재 미불금"; } else if($biztype=='2'){ $where .= " and biztype = '2' "; }
if($stx!=''){ $where .= " and {$sti} like '%{$stx}%' "; }
if($biztype=='1'){ $cur_var = "cur_recvbl"; } else if($biztype=='0'){ $cur_var = "cur_arrear"; }
$sql = "select a.code1, a.comp_name, a.ceo_name, a.telno, a.hpno, a.faxno, a.comp_sn, a.{$cur_var}, a.zipcode, a.addr_m, a.addr_d, a.biz_status, a.biz_item, a.vattype, a.email, a.memo, a.tax_charge_name, a.tax_charge_hpno, a.biztype from customers a WHERE 1=1 $where order by comp_name "; $result = mysql_query($sql,$connect_e1000y); //echo $sql; exit;
while($cus_info=mysql_fetch_array($result)){ $list_array[] = $cus_info; }
//_pr($list_array); exit;
//echo dirname(__FILE__) . '/lib/phpexcel/PHPExcel.php'; require_once dirname(__FILE__) . '/lib/phpexcel/PHPExcel.php';
$objPHPExcel = new PHPExcel();
/*$objPHPExcel->getActiveSheet()->getStyle('A1:S1')->getAlignment()->setWrapText(true); // 워드랩 기능 추가 $objPHPExcel->getActiveSheet()->getStyle('A1:S1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);*/
$title_array = Array("코드","상호명","대표자","전화번호","핸드폰번호","팩스번호","사업자번호",$biztype_misu,"우편번호","주소","번지","업태","종목","부가세구분","이메일","비고","세금계산서 담당자","세금계산서 핸드폰","거래구분");
for($i=0;$i<count($title_array);$i++){ if($i>25){ $vv = floor($i/26); $v = $i-(26*$vv); $alpha = chr(65+$v); $alpha = chr(64+$vv).$alpha; } else { $alpha = chr(65+$i); } $objPHPExcel->setActiveSheetIndex(0) ->setCellValue($alpha.'1', $title_array[$i]); $objPHPExcel->getActiveSheet()->getColumnDimension($alpha)->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension($alpha)->setAutoSize(true); }
for($i=0;$i<count($list_array);$i++){ $it = $list_array[$i]; $x = 0; $xx = 0; foreach($it as $key => $val){ if($xx%2==0){ if($x>25){ $vv = floor($x/26); $v = $x-(26*$vv); $alpha = chr(65+$v); $alpha = chr(64+$vv).$alpha; } else { $alpha = chr(65+$x); }
if($key=='18'){ if($val=='0'){ $val = "매입처"; } else if($val=='1') { $val = "매출처"; } }
$objPHPExcel->setActiveSheetIndex(0) ->setCellValue($alpha.($i+2), $val); $x++; } $xx++; } }
$objPHPExcel->getActiveSheet()->setTitle('customers'); $objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a client’s web browser (Excel5) header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="customers_'.date("Ymd",time()).'.xls"'); 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, 'Excel5'); $objWriter->save('php://output');
?>
|