/home/mjc1/public_html/j3demo/xls_update.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
<?php
include("./_common.php");

//echo "막혔음"; exit;

$f1['fname'] = "./data/폴란드어-khh-CWA Inspection Language 요청 190918-1_한폴_Checked.xls";
$f1['sheet'][0]['name'] = '255';
$f1['sheet'][0]['rows'] = 1;
$f1['sheet'][0]['cols'] = 1387;
$f1['sheet'][1]['name'] = '256';
$f1['sheet'][1]['rows'] = 1;
$f1['sheet'][1]['cols'] = 3031;
$f1['sheet'][2]['name'] = '257';
$f1['sheet'][2]['rows'] = 1;
$f1['sheet'][2]['cols'] = 637;
$f1['sheet'][3]['name'] = '258';
$f1['sheet'][3]['rows'] = 1;
$f1['sheet'][3]['cols'] = 442;
$xls_file[] = $f1;

$f2['fname'] = "./data/폴란드어-khh-CWA Stacking Language 요청 190918-1_한폴_Checked.xls";
$f2['sheet'][0]['name'] = '3';
$f2['sheet'][0]['rows'] = 1;
$f2['sheet'][0]['cols'] = 1856;
$f2['sheet'][1]['name'] = '255';
$f2['sheet'][1]['rows'] = 1;
$f2['sheet'][1]['cols'] = 978;
$f2['sheet'][2]['name'] = '256';
$f2['sheet'][2]['rows'] = 1;
$f2['sheet'][2]['cols'] = 2959;
$f2['sheet'][3]['name'] = '257';
$f2['sheet'][3]['rows'] = 1;
$f2['sheet'][3]['cols'] = 103;

$xls_file[] = $f2;

$f3['fname'] = "./data/폴란드어-khh-CWA Taping Language 요청 190918-2_한폴_Checked.xls";
$f3['sheet'][0]['name'] = '3';
$f3['sheet'][0]['rows'] = 1;
$f3['sheet'][0]['cols'] = 895;
$f3['sheet'][1]['name'] = '254';
$f3['sheet'][1]['rows'] = 1;
$f3['sheet'][1]['cols'] = 7985;
$f3['sheet'][2]['name'] = '255';
$f3['sheet'][2]['rows'] = 1;
$f3['sheet'][2]['cols'] = 2972;
$f3['sheet'][3]['name'] = '256';
$f3['sheet'][3]['rows'] = 1;
$f3['sheet'][3]['cols'] = 291;
$f3['sheet'][4]['name'] = '257';
$f3['sheet'][4]['rows'] = 1;
$f3['sheet'][4]['cols'] = 711;
$f3['sheet'][5]['name'] = '258';
$f3['sheet'][5]['rows'] = 1;
$f3['sheet'][5]['cols'] = 910;
$xls_file[] = $f3;

$f4['fname'] = "./data/폴란드어-khh-CWA Unloader Language 요청 190918-1_한폴_Checked.xls";
$f4['sheet'][0]['name'] = '255';
$f4['sheet'][0]['rows'] = 1;
$f4['sheet'][0]['cols'] = 889;
$f4['sheet'][1]['name'] = '256';
$f4['sheet'][1]['rows'] = 1;
$f4['sheet'][1]['cols'] = 649;
$xls_file[] = $f4;

include_once(
$j3_lib_path.'/Excel/reader.php');

$fp fopen("./data/sql_list.sql",w);

for(
$x=0;$x<count($xls_file);$x++){
    if(
$x=='0' || $x=='1' || $x=='2'){ continue; }
    
$f_idx $x;
    
$file $xls_file[$f_idx]['fname'];
    
$rows $xls_file[$f_idx]['rows'];
    
$cols $xls_file[$f_idx]['cols'];

    
$data = new Spreadsheet_Excel_Reader();

    
// Set output Encoding.
    
$data->setOutputEncoding('ISO-8859-2');

    
$data->read($file);


    
error_reporting(E_ALL E_NOTICE);

    foreach(
$xls_file[$f_idx]['sheet'] as $key=>$sheets){
        
//_pr($key);
        
$rows $sheets['rows'];
        
$cols =$sheets['cols'];

        
$cnt 0;
        for(
$i=1;$i<=$cols;$i++){
            for(
$j=1;$j<=$rows;$j++){
                
$code addslashes($data->sheets[$key]['cells'][$i][$j]);
                
//$code = iconv("utf-8","windows-1258",$code);
                
$code iconv('ISO-8859-2''UTF-8//TRANSLIT'$code);
                if(
$code!=''){
                    
$sql "update xls_reader set xls_conv = '{$code}' where xls_file = '{$f_idx}' and xls_alpha = '{$j}' and xls_no = '{$i}' and xls_sheet = '{$key}'; ";
                    
fwrite($fp,$sql.chr(10));
                    
//_pr($sql);
                    
mysql_query($sql,$connect_j3);
                }
                
$cnt++;
            }
        }
    }
    
//_pr($cnt);

    /*$cnt = 0;
    for($i=1;$i<=$cols;$i++){
        for($j=1;$j<=$rows;$j++){
            $code = addslashes($data->sheets[0]['cells'][$i][$j]);
            //$sql = "insert into xls_reader set xls_file = '{$f_idx}', xls_alpha = '{$j}', xls_no = '{$i}', xls_content = '{$code}' ";
            $sql = "update xls_reader set xls_conv = '{$code}' where xls_file = '{$f_idx}' and xls_alpha = '{$j}' and xls_no = '{$i}' ";
            //_pr($sql);
            mysql_query($sql,$connect_j3);

            //if($cnt==100){ exit; }
            $cnt++;
        }
    }*/
}

fclose($fp);
@
chmod("./data/sql_list.sql",0707);
// 베트남어 일부는 UTF-8로 받아도 깨지는경우가 있어서 아래와 같이 변경 처리함
// _pr로 sql문을 화면을 IE11에서 읽은 다음 인코딩 베트남처리 해서 전체 복사후에 HeideSQL에 붙혀넣기후에 실행처리



?>