/home/mjc1/public_html/j3demo/adm/order_deli_xls.php


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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
include("./_common.php");

if(
$order_key==''){ 
    if(
$_COOKIE['ok_product']!=''){
        
$_COOKIE['ok_product'] = str_replace("%20"," ",$_COOKIE['ok_product']);
        
$order_key $_COOKIE['ok_product']; 
    } else {
        
$order_key 'a.code1 desc'
    }
}

$where2 "  ";

$where2 .= " and ordstate = '1' ";

if(
$sdate!=''){
    
$where2 .= " and b.orddate >= '{$sdate}' ";
}
if(
$edate!=''){
    
$where2 .= " and b.orddate <= '{$edate}' ";
}
if(
$pay_type!=''){
    
$where2 .= " and pay_type = '{$pay_type}' ";
}

$stx urldecode($stx);
if(
$stx!=''){
    if(
$sti=='pname'){ // 상품명일때 처리
        
$pname_s $stx;
    } else {
        
$where2 .= " and {$sti} like '%{$stx}%' ";
    }
}

if (
$page 1) { $page 1; } // 페이지가 없으면 첫 페이지 (1 페이지)

$sql "select od_id, deli_company, tracking_number
            from sale_ord_s s 
            inner join sale_ord_m m on s.midx = m.midx
            WHERE 1=1 
{$where2}
            ORDER BY s.midx DESC
            LIMIT 0,999999"
;

$res mysql_query($sql,$connect_j3);
while(
$ordinfo=mysql_fetch_object($res)){
    
$info null;
    
$col_cnt 0;
    foreach(
$ordinfo as $key=>$val){
        
$info[$key] = $val;
        
$col_cnt++;
    }
    
$list_array[] = $info;
}


$qstr $_SERVER['QUERY_STRING'];

$title_array = Array("주문번호","배송업체","운송장번호");

require_once 
$j3_lib_path."/phpexcel/PHPExcel.php";

$objPHPExcel = new PHPExcel();

$objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:C1');
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1','* 운송장 업로드용 배송준비 엑셀');
$objPHPExcel->getActiveSheet()->getStyle('A1:Z1')->getAlignment()->setWrapText(true); // 워드랩 기능 추가
$objPHPExcel->getActiveSheet()->getStyle('A1:Z1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(140); // 높이 조절

for($i=0;$i<$col_cnt;$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->getActiveSheet()->getColumnDimension($alpha)->setAutoSize(true);
}

for(
$i=0;$i<$col_cnt;$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.'2'$title_array[$i]);
}

for(
$i=0;$i<count($list_array);$i++){
    
$info $list_array[$i];
    
$x 0;
    foreach(
$info as $key => $val){
        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($x==16){ $val = addslashes($val); }

        
if($alpha=="A"){
            
$objPHPExcel->getActiveSheet()->setCellValueExplicit($alpha.($i+3), $val,PHPExcel_Cell_DataType::TYPE_STRING); 
        } else {
            
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($alpha.($i+3), $val);
        }
        
$x++;
    }
}


$objPHPExcel->getActiveSheet()->setTitle('주문리스트');
$objPHPExcel->setActiveSheetIndex(0);

// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="orderlist_xls'.$limit.'.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');
?>