Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-rpc
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
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
without authentication
meibuyu-rpc
Commits
d838a8dc
Commit
d838a8dc
authored
May 29, 2020
by
梁俊杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
链式操作增强
parent
237dd751
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
16 deletions
+9
-16
Exporter.MD
Exporter.MD
+8
-16
Exporter.php
src/Tools/Exporter.php
+1
-0
No files found.
Exporter.MD
View file @
d838a8dc
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
//填充表头
//填充表头
$title = ['产品','颜色','尺码','sku']
$title = ['产品','颜色','尺码','sku']
$exporter->append($title);
//填充数据
$list = Product::with(["color","size"])->get()->toArray();
$list = Product::with(["color","size"])->get()->toArray();
$exporter->append($list,['name','color.name','size.name|未设定尺码','sku']);
$exporter->append($title)
->append($list,['name','color.name','size.name|未设定尺码','sku'])//填充数据
//设置保护
->setUnprotectRange("A1:B".$exporter->getCurrentRowIndex())//设置保护
$exporter->setUnprotectRange("A1:B".$exporter->getCurrentRowIndex());
->download(Exporter::DOWNLOAD_TYPE_STREAM,"产品数据");//下载数据
$exporter->download(Exporter::DOWNLOAD_TYPE_STREAM,"产品数据");
```
```
2、导出Excel,使用模板的情况
2、导出Excel,使用模板的情况
...
@@ -28,15 +23,12 @@
...
@@ -28,15 +23,12 @@
$exporter->addSheet('颜色参考表', true);
$exporter->addSheet('颜色参考表', true);
//填充表头
//填充表头
$title = ['颜色id','中文颜色名','英文颜色名']
$title = ['颜色id','中文颜色名','英文颜色名']
$exporter->append($title);
$exporter->append($title)
$exporter->append(Color::get(["id", "cn_name", "en_name"]));
->append(Color::get(["id", "cn_name", "en_name"]))
->setUnprotectRange();//全表保护
//设置保护
//设置保护
$exporter->setUnprotectRange();//全表保护
//使用别的sheet表
//使用别的sheet表
$exporter->setSheetByIndex(0);
$exporter->setSheetByIndex(0)->setBeginRowIndex(2)->setBeginColumnChar("C");//从第三列开始填充数据
$exporter->setBeginRowIndex(2);//从第二行开始填充数据
$exporter->setBeginColumnChar("C");//从第三列开始填充数据
//填充数据
//填充数据
$list = Product::with(["color","size"])->get()->toArray();
$list = Product::with(["color","size"])->get()->toArray();
$exporter->append($list,['name','color.name','size.name|未设定尺码','sku']);
$exporter->append($list,['name','color.name','size.name|未设定尺码','sku']);
...
...
src/Tools/Exporter.php
View file @
d838a8dc
...
@@ -127,6 +127,7 @@ class Exporter
...
@@ -127,6 +127,7 @@ class Exporter
if
(
$activeSheet
)
{
if
(
$activeSheet
)
{
$this
->
setSheetByName
(
$name
);
$this
->
setSheetByName
(
$name
);
}
}
return
$this
;
}
}
/** 根据名字sheet表名激化切换到 该表
/** 根据名字sheet表名激化切换到 该表
...
...
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