Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
23d41d7b
Commit
23d41d7b
authored
Aug 20, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
b53f8a89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
29 deletions
+4
-29
ReadExcel.php
application/index/controller/ReadExcel.php
+4
-29
No files found.
application/index/controller/ReadExcel.php
View file @
23d41d7b
...
...
@@ -36,8 +36,8 @@ class ReadExcel extends Basic
$path
=
$_FILES
[
'excel'
][
'tmp_name'
];
// $file = $_FILES['upload']['tmp_name'][0];
$data
=
$this
->
import_excel
(
$path
);
dump
(
$
data
);
dump
(
$
path
);
...
...
@@ -47,33 +47,7 @@ class ReadExcel extends Basic
}
private
function
import_excel
(
$file
){
// 判断文件是什么格式
$type
=
pathinfo
(
$file
);
$type
=
strtolower
(
$type
[
"extension"
]);
$type
=
$type
===
'csv'
?
$type
:
'Excel5'
;
ini_set
(
'max_execution_time'
,
'0'
);
Vendor
(
'PHPExcel.PHPExcel'
);
// 判断使用哪种格式
$objReader
=
\PHPExcel_IOFactory
::
createReader
(
$type
);
$objPHPExcel
=
$objReader
->
load
(
$file
);
$sheet
=
$objPHPExcel
->
getSheet
(
0
);
// 取得总行数
$highestRow
=
$sheet
->
getHighestRow
();
// 取得总列数
$highestColumn
=
$sheet
->
getHighestColumn
();
//循环读取excel文件,读取一条,插入一条
$data
=
array
();
//从第一行开始读取数据
for
(
$j
=
3
;
$j
<=
$highestRow
;
$j
++
){
//从A列读取数据
for
(
$k
=
'A'
;
$k
<=
$highestColumn
;
$k
++
){
// 读取单元格
$data
[
$j
][]
=
$objPHPExcel
->
getActiveSheet
()
->
getCell
(
"
$k$j
"
)
->
getValue
();
}
}
return
$data
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment