Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
without authentication
meibuyu-micro
Commits
58bc0265
Commit
58bc0265
authored
Aug 26, 2023
by
Liu lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Vtiful\Kernel\Excel 优化
parent
4a6ce053
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
KernelExcelExportService.php
src/Tools/KernelExcelExportService.php
+9
-3
No files found.
src/Tools/KernelExcelExportService.php
View file @
58bc0265
...
@@ -47,17 +47,17 @@ class KernelExcelExportService
...
@@ -47,17 +47,17 @@ class KernelExcelExportService
private
$dataRowStart
=
2
;
//起始行
private
$dataRowStart
=
2
;
//起始行
/**
/**
*
*
@param $sheetName
* KernelExcelExportService constructor.
* KernelExcelExportService constructor.
* @param $dir 文件存储目录
* @param $dir 文件存储目录
* @param $fileName 导出文件名 默认加上时间
* @param $fileName 导出文件名 默认加上时间
*/
*/
public
function
__construct
(
$dir
,
$fileName
)
public
function
__construct
(
$dir
,
$fileName
,
$sheetName
=
'Sheet1'
)
{
{
$fileName
=
"
{
$fileName
}
_"
.
date
(
'YmdHis'
)
.
'.xlsx'
;
$fileName
=
"
{
$fileName
}
_"
.
date
(
'YmdHis'
)
.
'.xlsx'
;
$dir
=
BASE_PATH
.
'/public/export/'
.
$dir
;
$dir
=
BASE_PATH
.
'/public/export/'
.
$dir
;
!
is_dir
(
$dir
)
&&
!
mkdir
(
$dir
,
0777
,
true
);
//不存在则创建
!
is_dir
(
$dir
)
&&
!
mkdir
(
$dir
,
0777
,
true
);
//不存在则创建
$this
->
fileObject
=
(
new
\Vtiful\Kernel\Excel
([
'path'
=>
$dir
]))
->
constMemory
(
$fileName
);
$this
->
fileObject
=
(
new
\Vtiful\Kernel\Excel
([
'path'
=>
$dir
]))
->
constMemory
(
$fileName
,
$sheetName
);
}
}
/**
/**
...
@@ -68,6 +68,12 @@ class KernelExcelExportService
...
@@ -68,6 +68,12 @@ class KernelExcelExportService
return
$this
->
fileObject
;
return
$this
->
fileObject
;
}
}
public
function
addSheet
(
$sheetName
)
{
$this
->
dataRowStart
=
2
;
$this
->
fileObject
->
addSheet
(
$sheetName
);
}
/**
/**
* 设置居中样式
* 设置居中样式
...
...
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