Commit 2a32c9df authored by 王源's avatar 王源 🎧

调整Exporter导出类中模板文件所在文件夹路径

parent 22b4f9ba
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
2、导出Excel,使用模板的情况 2、导出Excel,使用模板的情况
```$xslt ```$xslt
//根据模板导出器 //根据模板导出器
$exporter = new Exporter(Exporter::EXPORTER_TYPE_XLSX,'导出产品信息','template/xxx.xlsx');#使用模板来生成 $exporter = new Exporter(Exporter::EXPORTER_TYPE_XLSX, 'template/xxx.xlsx', '导出产品信息');#使用模板来生成
......
...@@ -61,7 +61,7 @@ class Exporter ...@@ -61,7 +61,7 @@ class Exporter
/** /**
* Exporter constructor. * Exporter constructor.
* @param int $export_type 类型 * @param int $export_type 类型
* @param string $tempFilePath 模板文件地址 * @param string $tempFilePath 模板文件地址 (请放置在项目根目录的storage目录下)
* @param string $name 名称 * @param string $name 名称
* @param int $sheetIndex * @param int $sheetIndex
* @throws PhpSpreadsheetException * @throws PhpSpreadsheetException
...@@ -72,7 +72,7 @@ class Exporter ...@@ -72,7 +72,7 @@ class Exporter
$this->config = container(ConfigInterface::class); $this->config = container(ConfigInterface::class);
$this->rootPath = $this->config->get('server.settings.document_root', BASE_PATH . '/public'); $this->rootPath = $this->config->get('server.settings.document_root', BASE_PATH . '/public');
if ($tempFilePath) { if ($tempFilePath) {
$tempFilePath = $this->rootPath . "/" . $tempFilePath; $tempFilePath = BASE_PATH . '/storage/' . $tempFilePath;
if (file_exists($tempFilePath)) { if (file_exists($tempFilePath)) {
$this->fileType = ucfirst(strtolower(pathinfo($tempFilePath, PATHINFO_EXTENSION))); $this->fileType = ucfirst(strtolower(pathinfo($tempFilePath, PATHINFO_EXTENSION)));
$reader = IOFactory::createReader($this->fileType)->load($tempFilePath); $reader = IOFactory::createReader($this->fileType)->load($tempFilePath);
......
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