Commit da790757 authored by 王源's avatar 王源 🎧

Merge branch 'develop' into test

parents c9454cdf 2a32c9df
......@@ -15,7 +15,7 @@
2、导出Excel,使用模板的情况
```$xslt
//根据模板导出器
$exporter = new Exporter(Exporter::EXPORTER_TYPE_XLSX,'导出产品信息','template/xxx.xlsx');#使用模板来生成
$exporter = new Exporter(Exporter::EXPORTER_TYPE_XLSX, 'template/xxx.xlsx', '导出产品信息');#使用模板来生成
......
......@@ -24,26 +24,26 @@ class Exporter
/**
* 以字节流的形式下载
*/
CONST DOWNLOAD_TYPE_STREAM = 1;
const DOWNLOAD_TYPE_STREAM = 1;
/**
* 保存文件,并返回文件的路径
*/
CONST DOWNLOAD_TYPE_RETURN_FILE_PATH = 2;
const DOWNLOAD_TYPE_RETURN_FILE_PATH = 2;
/**
* 保存文件,直接输出下载
*/
CONST DOWNLOAD_TYPE_SAVE_AND_DOWNLOAD = 3;
const DOWNLOAD_TYPE_SAVE_AND_DOWNLOAD = 3;
/**
* 保存文件,返回文件绝对路径
*/
CONST DOWNLOAD_TYPE_RETURN_ABSOLUTE_PATH = 4;
const DOWNLOAD_TYPE_RETURN_ABSOLUTE_PATH = 4;
CONST EXPORTER_TYPE_CSV = 1;
CONST EXPORTER_TYPE_XLS = 2;
CONST EXPORTER_TYPE_XLSX = 3;
const EXPORTER_TYPE_CSV = 1;
const EXPORTER_TYPE_XLS = 2;
const EXPORTER_TYPE_XLSX = 3;
/**
* @var ConfigInterface
*/
......@@ -61,7 +61,7 @@ class Exporter
/**
* Exporter constructor.
* @param int $export_type 类型
* @param string $tempFilePath 模板文件地址
* @param string $tempFilePath 模板文件地址 (请放置在项目根目录的storage目录下)
* @param string $name 名称
* @param int $sheetIndex
* @throws PhpSpreadsheetException
......@@ -72,7 +72,7 @@ class Exporter
$this->config = container(ConfigInterface::class);
$this->rootPath = $this->config->get('server.settings.document_root', BASE_PATH . '/public');
if ($tempFilePath) {
$tempFilePath = $this->rootPath . "/" . $tempFilePath;
$tempFilePath = BASE_PATH . '/storage/' . $tempFilePath;
if (file_exists($tempFilePath)) {
$this->fileType = ucfirst(strtolower(pathinfo($tempFilePath, PATHINFO_EXTENSION)));
$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