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
f295994c
Commit
f295994c
authored
Aug 20, 2019
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
9dd5bcac
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
0 deletions
+91
-0
StoreFeeService.php
application/api_broker/service/StoreFeeService.php
+38
-0
ReadExcel.php
application/index/controller/ReadExcel.php
+28
-0
StoreFee.php
application/index/controller/StoreFee.php
+25
-0
No files found.
application/api_broker/service/StoreFeeService.php
View file @
f295994c
...
...
@@ -748,4 +748,41 @@ class StoreFeeService
}
dump
(
$data
);
}
/**
* 门店考勤列表-批量上传
* @param $file_path
* @return string
*/
public
function
readStoreFee
(
$file_path
)
{
$reader
=
new
\PhpOffice\PhpSpreadsheet\Reader\Xlsx
();
$reader
->
setReadDataOnly
(
true
);
$spreadsheet
=
""
;
try
{
$spreadsheet
=
$reader
->
load
(
$file_path
);
}
catch
(
\Exception
$exception
)
{
return
"找不到文件路径"
;
}
$sheet
=
$spreadsheet
->
getActiveSheet
();
$highestRow
=
$sheet
->
getHighestRow
();
// 最大行数
$highestColumn
=
$sheet
->
getHighestColumn
();
// 最大列数
$highestColumn
=
"AB"
;
// 把下标变成数字,如A-Z分别对应1-26,AA对应27,AB对应28,以此类推
$highestColumnIndex
=
\PhpOffice\PhpSpreadsheet\Cell\Coordinate
::
columnIndexFromString
(
$highestColumn
);
/* if($highestRow <= 2){ // 因为students.xlsx表格数据是从第三行开始的
exit('Excel没有任何数据');
}*/
$data
=
array
();
for
(
$row
=
0
;
$row
<=
$highestRow
;
$row
++
)
{
$tempData
[
'name'
]
=
$sheet
->
getCellByColumnAndRow
(
1
,
$row
)
->
getValue
();
$tempData
[
'chinese'
]
=
$sheet
->
getCellByColumnAndRow
(
2
,
$row
)
->
getValue
();
$tempData
[
'math'
]
=
$sheet
->
getCellByColumnAndRow
(
3
,
$row
)
->
getValue
();
$tempData
[
'English'
]
=
$sheet
->
getCellByColumnAndRow
(
4
,
$row
)
->
getValue
();
$data
[]
=
$tempData
;
}
dump
(
$data
);
}
}
\ No newline at end of file
application/index/controller/ReadExcel.php
View file @
f295994c
...
...
@@ -37,6 +37,34 @@ class ReadExcel extends Basic
$path
=
$_FILES
[
'excel'
][
'tmp_name'
];
// $file = $_FILES['upload']['tmp_name'][0];
$reader
=
new
\PhpOffice\PhpSpreadsheet\Reader\Xlsx
();
$reader
->
setReadDataOnly
(
true
);
$spreadsheet
=
""
;
try
{
$spreadsheet
=
$reader
->
load
(
$path
);
}
catch
(
\Exception
$exception
)
{
return
"找不到文件路径"
;
}
$sheet
=
$spreadsheet
->
getActiveSheet
();
$highestRow
=
$sheet
->
getHighestRow
();
// 最大行数
$highestColumn
=
$sheet
->
getHighestColumn
();
// 最大列数
$highestColumn
=
"AB"
;
// 把下标变成数字,如A-Z分别对应1-26,AA对应27,AB对应28,以此类推
$highestColumnIndex
=
\PhpOffice\PhpSpreadsheet\Cell\Coordinate
::
columnIndexFromString
(
$highestColumn
);
/* if($highestRow <= 2){ // 因为students.xlsx表格数据是从第三行开始的
exit('Excel没有任何数据');
}*/
$data
=
array
();
for
(
$row
=
1
;
$row
<=
$highestRow
;
$row
++
)
{
$tempData
[
'name'
]
=
$sheet
->
getCellByColumnAndRow
(
1
,
$row
)
->
getValue
();
$tempData
[
'chinese'
]
=
$sheet
->
getCellByColumnAndRow
(
2
,
$row
)
->
getValue
();
$tempData
[
'math'
]
=
$sheet
->
getCellByColumnAndRow
(
3
,
$row
)
->
getValue
();
$tempData
[
'English'
]
=
$sheet
->
getCellByColumnAndRow
(
4
,
$row
)
->
getValue
();
$data
[]
=
$tempData
;
}
dump
(
$data
);
dump
(
$path
);
...
...
application/index/controller/StoreFee.php
View file @
f295994c
...
...
@@ -575,4 +575,28 @@ class StoreFee extends Basic
}
return
$this
->
response
(
$code
,
$msg
);
}
/**
* 门店考勤列表-批量上传
* @return \think\Response
*/
public
function
readStoreFee
()
{
header
(
'Access-Control-Allow-Origin:*'
);
set_time_limit
(
0
);
$file
=
$_FILES
[
'file'
];
$type
=
request
()
->
param
(
'type'
);
$uploadFileService
=
new
UploadFileService
();
$uploadResult
=
$uploadFileService
->
upload
(
$file
,
$type
,
15000000
,
[
'xls'
,
'xlsx'
]);
if
(
$uploadResult
[
"code"
]
==
200
)
{
$path
=
$_FILES
[
'excel'
][
'tmp_name'
];
$result
=
$this
->
service_
->
readStoreFee
(
$path
);
return
$this
->
response
(
"200"
,
"excel上传成功"
,
$uploadResult
[
"msg"
]);
}
else
{
return
$this
->
response
(
"101"
,
$uploadResult
[
"msg"
]);
}
}
}
\ 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