01.
02.
require_once
'PHPExcel-18/Classes/PHPExcel.php'
;
03.
04.
05.
include
'PHPExcel/Classes/PHPExcel/IOFactory.php'
;
06.
echo
'<meta http-equiv="Content-type" content="text/html;charset=tis-620" />'
;
07.
$inputFileName
=
"import/"
.
$name_file
;
08.
$inputFileType
= PHPExcel_IOFactory::identify(
$inputFileName
);
09.
$objReader
= PHPExcel_IOFactory::createReader(
$inputFileType
);
10.
$objReader
->setReadDataOnly(true);
11.
$objPHPExcel
=
$objReader
->load(
$inputFileName
);
12.
13.
14.
$objWorksheet
=
$objPHPExcel
->setActiveSheetIndex(0);
15.
$highestRow
=
$objWorksheet
->getHighestRow();
16.
$highestColumn
=
$objWorksheet
->getHighestColumn();
17.
18.
$r
= -1;
19.
$namedDataArray
=
array
();
20.
for
(
$row
= 2;
$row
<=
$highestRow
; ++
$row
) {
21.
$dataRow
=
$objWorksheet
->rangeToArray(
'A'
.
$row
.
':'
.
$highestColumn
.
$row
,null, true, true, true);
22.
if
((isset(
$dataRow
[
$row
][
'A'
])) && (
$dataRow
[
$row
][
'A'
] >
''
)) {
23.
++
$r
;
24.
$namedDataArray
[
$r
] =
$dataRow
[
$row
];
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.
$row_data
= -1;
51.
foreach
(
$namedDataArray
as
$result
) {
52.
$row_data
++;
53.
54.
$inputdata
[] =
array
(
55.
"head_1"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"A"
]),
56.
"head_2"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"B"
]),
57.
"head_3"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"C"
]),
58.
"Char_1"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"D"
]),
59.
"Char_2"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"E"
]),
60.
"Char_3"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"F"
]),
61.
"Char_4"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"G"
]),
62.
"Char_5"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"H"
]),
63.
"Char_6"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"I"
]),
64.
"Char_7"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"J"
]),
65.
"Char_8"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"K"
]),
66.
"Char_9"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"L"
]),
67.
"Char_10"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"M"
]),
68.
"Char_11"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"N"
]),
69.
"Char_12"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"O"
]),
70.
"Char_13"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"P"
]),
71.
"Char_14"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"Q"
]),
72.
"Char_15"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"R"
]),
73.
"Char_16"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"S"
]),
74.
"Char_17"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"T"
]),
75.
"Char_18"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"U"
]),
76.
"Char_19"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"V"
]),
77.
"Char_20"
=>iconv(
'UTF-8'
,
'TIS-620'
,
$result
[
"W"
]),
78.
);
79.
}
80.
81.
82.
$file_del
=
"import/"
.
$name_file
;
83.
@unlink(
$file_del
);
84.
85.
86.
87.
88.
89.
90.
91.
92.
}