From a62020650c6c64d1c5dbc8d329d089e4e14687fb Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Wed, 21 Oct 2020 13:54:55 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=96=B0=E5=A2=9E=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchModelCollection.php | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/extend/catcher/CatchModelCollection.php b/extend/catcher/CatchModelCollection.php index 05751de..90d1e1d 100644 --- a/extend/catcher/CatchModelCollection.php +++ b/extend/catcher/CatchModelCollection.php @@ -1,12 +1,70 @@ items, $pid, $pidField, $children); } + + + /** + * 导出数据 + * + * @time 2020年10月21日 + * @param $header + * @param string $path + * @param string $disk + * @throws \PhpOffice\PhpSpreadsheet\Exception + * @return mixed|string[] + */ + public function export($header, $path = '', $disk = 'local') + { + $excel = new Class($header, $this->items) implements ExcelContract + { + protected $headers; + + protected $sheets; + + public function __construct($headers, $sheets) + { + $this->headers = $headers; + + $this->sheets = $sheets; + } + + public function headers(): array + { + // TODO: Implement headers() method. + return $this->headers; + } + + public function sheets() + { + // TODO: Implement sheets() method. + return $this->sheets; + } + }; + + if (!$path) { + $path = Utils::publicPath('exports'); + } + + return (new Excel)->save($excel, $path, $disk); + } } \ No newline at end of file