Commit 72eac1eb authored by Liu lu's avatar Liu lu

Vtiful\Kernel\Excel 优化

parent 8ba04e65
......@@ -71,23 +71,31 @@ class KernelExcelExportService
/**
* 设置居中样式
* @param $width 列宽
* @param $width 固定自动列宽
* @param $definedWith 自定义列宽
* @author Liu lu
* date 2023-04-14
*/
public function setDefaultStyle($width=12)
public function setDefaultStyle($autoWidth=12,$definedWith=null)
{
$fileHandle = $this->fileObject->getHandle();
$alignStyle = (new \Vtiful\Kernel\Format($fileHandle))
->align( \Vtiful\Kernel\Format::FORMAT_ALIGN_JUSTIFY)
->align( \Vtiful\Kernel\Format::FORMAT_ALIGN_CENTER)
->align( \Vtiful\Kernel\Format::FORMAT_ALIGN_VERTICAL_CENTER)
->toResource();
$this->fileObject->setColumn(
'A:'.Coordinate::stringFromColumnIndex(count($this->headers)), $width, $alignStyle
);
if(is_null($definedWith)){
$this->fileObject->setColumn(
'A:'.Coordinate::stringFromColumnIndex(count($this->headers)), $autoWidth, $alignStyle
);
}else{
foreach ($definedWith as $columnTag=>$width){
$this->fileObject->setColumn(
$columnTag, $width, $alignStyle
);
}
}
return $this;
}
......
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