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
|
<?php $dir = "."; include_once($dir."/_common.php");
if($eid==''){ alert('e천년경영 로그인 후에 이용가능합니다.',"index.php"); exit; }
$where = " ";
if($stx!=''){ $where .= " and {$sti} like '%{$stx}%' "; }
if($stc!=''){ $where .= " and prod_cate_code = '{$stc}' "; }
if($stpc!=''){ $where .= " and prod_cate_code2 = '{$stpc}' "; }
$sql = "select a.code1, a.name, a.norm, d.name as cate_name, e.name as cate2_name, a.pce_bcode1, a.tax_yn, a.prod_wt, a.unit, a.remarks, b.buyprice, b.saleprice from product_m a left join product_d b on a.code = b.pcode left join product_category d on a.prod_cate_code = d.code left join product_category2 e on a.prod_cate_code2 = e.code WHERE 1=1 $where and ocode = '1' order by code1 desc "; $result = mysql_query($sql,$connect_e1000y);
//_pr($sql); while($cus_info=mysql_fetch_array($result)){ $list_array[] = $cus_info; }
require_once dirname(__FILE__) . '/lib/phpexcel/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$title_array = Array("코드","상품명","규격","분류","상품그룹","바코드","부가세","무게","단위","비고","매입단가","매출단가");
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=='6'){ if($val=='0'){ $val = "면세"; } else if($val=='1') { $val = "과세"; } else if($val=='2') { $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="product_'.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'); ?>
|