Commit 7eec3a61 authored by 王源's avatar 王源 🎧

优化导入导出工具栏

parent eb7d7c1c
...@@ -208,6 +208,15 @@ class ExcelImporter ...@@ -208,6 +208,15 @@ class ExcelImporter
return $this->highestRow; return $this->highestRow;
} }
/**
* 获取总列数
* @return int
*/
public function getHighestColumn()
{
return $this->highestColumn;
}
/** /**
* 返回文件本地地址 * 返回文件本地地址
* @return string * @return string
......
...@@ -272,7 +272,7 @@ class Exporter ...@@ -272,7 +272,7 @@ class Exporter
'borders' => [ 'borders' => [
'allBorders' => [ 'allBorders' => [
'borderStyle' => Border::BORDER_THIN, 'borderStyle' => Border::BORDER_THIN,
'color' => ['argb' => '666'], 'color' => ['argb' => '000000'],
], ],
], ],
'alignment' => [ 'alignment' => [
...@@ -286,6 +286,23 @@ class Exporter ...@@ -286,6 +286,23 @@ class Exporter
$this->sheet->getStyle($pRange)->applyFromArray($styleArray); $this->sheet->getStyle($pRange)->applyFromArray($styleArray);
} }
/**
* 设置列宽
* @param int $width 不传为自动宽度
*/
public function setColumnWidth(int $width = null)
{
$end = $this->sheet->getHighestColumn();
$end++;
for ($i = 'A'; $i !== $end; $i++) {
if ($width) {
$this->sheet->getColumnDimension($i)->setWidth($width);
} else {
$this->sheet->getColumnDimension($i)->setAutoSize(true);
}
}
}
/** /**
* 下载导出的文件 * 下载导出的文件
* @param int $downloadType 下载形式 支持 Exporter::DOWNLOAD_TYPE_STREAM Exporter::DOWNLOAD_TYPE_RETURN_FILE_PATH Exporter::DOWNLOAD_TYPE_SAVE_AND_DOWNLOAD * @param int $downloadType 下载形式 支持 Exporter::DOWNLOAD_TYPE_STREAM Exporter::DOWNLOAD_TYPE_RETURN_FILE_PATH Exporter::DOWNLOAD_TYPE_SAVE_AND_DOWNLOAD
......
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