From 5face1c0774411ef63ffbfbf8bf29bf182eba5b3 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Tue, 26 May 2020 22:55:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96excel=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/library/excel/Excel.php | 10 +--------- extend/catcher/library/excel/MacroExcel.php | 13 +++++++++++++ extend/catcher/library/excel/ShouldTaskContract.php | 7 +++++++ 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 extend/catcher/library/excel/ShouldTaskContract.php diff --git a/extend/catcher/library/excel/Excel.php b/extend/catcher/library/excel/Excel.php index 6174a55..a06823e 100644 --- a/extend/catcher/library/excel/Excel.php +++ b/extend/catcher/library/excel/Excel.php @@ -61,25 +61,17 @@ class Excel */ protected function init() { - if (property_exists($this->excel, 'memory')) { - ini_set('memory_limit', $this->excel->memory); - } - + $this->setMemoryLimit(); // register worksheet for current excel $this->registerWorksheet(); - // before save excel $this->before(); - // set excel title $this->setTitle(); - // set excel headers $this->setExcelHeaders(); - // set cell width $this->setSheetWidth(); - // set worksheets $this->setWorksheets(); } diff --git a/extend/catcher/library/excel/MacroExcel.php b/extend/catcher/library/excel/MacroExcel.php index 9b4a437..a232fdf 100644 --- a/extend/catcher/library/excel/MacroExcel.php +++ b/extend/catcher/library/excel/MacroExcel.php @@ -163,4 +163,17 @@ trait MacroExcel { ++$this->row; } + + /** + * 设置内存限制 + * + * @time 2020年05月26日 + * @return void + */ + public function setMemoryLimit() + { + if (property_exists($this->excel, 'memory')) { + ini_set('memory_limit', $this->excel->memory); + } + } } diff --git a/extend/catcher/library/excel/ShouldTaskContract.php b/extend/catcher/library/excel/ShouldTaskContract.php new file mode 100644 index 0000000..d3bbf36 --- /dev/null +++ b/extend/catcher/library/excel/ShouldTaskContract.php @@ -0,0 +1,7 @@ +