Commit d838a8dc authored by 梁俊杰's avatar 梁俊杰

链式操作增强

parent 237dd751
......@@ -5,16 +5,11 @@
//填充表头
$title = ['产品','颜色','尺码','sku']
$exporter->append($title);
//填充数据
$list = Product::with(["color","size"])->get()->toArray();
$exporter->append($list,['name','color.name','size.name|未设定尺码','sku']);
//设置保护
$exporter->setUnprotectRange("A1:B".$exporter->getCurrentRowIndex());
$exporter->download(Exporter::DOWNLOAD_TYPE_STREAM,"产品数据");
$exporter->append($title)
->append($list,['name','color.name','size.name|未设定尺码','sku'])//填充数据
->setUnprotectRange("A1:B".$exporter->getCurrentRowIndex())//设置保护
->download(Exporter::DOWNLOAD_TYPE_STREAM,"产品数据");//下载数据
```
2、导出Excel,使用模板的情况
......@@ -28,15 +23,12 @@
$exporter->addSheet('颜色参考表', true);
//填充表头
$title = ['颜色id','中文颜色名','英文颜色名']
$exporter->append($title);
$exporter->append(Color::get(["id", "cn_name", "en_name"]));
$exporter->append($title)
->append(Color::get(["id", "cn_name", "en_name"]))
->setUnprotectRange();//全表保护
//设置保护
$exporter->setUnprotectRange();//全表保护
//使用别的sheet表
$exporter->setSheetByIndex(0);
$exporter->setBeginRowIndex(2);//从第二行开始填充数据
$exporter->setBeginColumnChar("C");//从第三列开始填充数据
$exporter->setSheetByIndex(0)->setBeginRowIndex(2)->setBeginColumnChar("C");//从第三列开始填充数据
//填充数据
$list = Product::with(["color","size"])->get()->toArray();
$exporter->append($list,['name','color.name','size.name|未设定尺码','sku']);
......
......@@ -127,6 +127,7 @@ class Exporter
if ($activeSheet) {
$this->setSheetByName($name);
}
return $this;
}
/** 根据名字sheet表名激化切换到 该表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment