四边边框

为单元格的上、右、下、左四条边分别指定不同的边框样式。

函数原型

borderOfTheFourSides(
    int $top    = Format::BORDER_NONE,
    int $right  = Format::BORDER_NONE,
    int $bottom = Format::BORDER_NONE,
    int $left   = Format::BORDER_NONE
): self

int $top / $right / $bottom / $left

四条边的边框样式,使用 Format::BORDER_* 常量(例如 BORDER_THINBORDER_MEDIUMBORDER_DASHED)。 任意参数省略或传 null 时,该方向不绘制边框。

需要为四条边分别指定颜色时,请配合 borderColorOfTheFourSides() 使用。

示例

$config = [
    'path' => './tests'
];

$excel      = new \Vtiful\Kernel\Excel($config);
$fileObject = $excel->fileName('tutorial.xlsx');
$fileHandle = $fileObject->getHandle();

$borderStyle = (new \Vtiful\Kernel\Format($fileHandle))
    ->borderOfTheFourSides(
        \Vtiful\Kernel\Format::BORDER_THIN,    //
        \Vtiful\Kernel\Format::BORDER_MEDIUM,  //
        \Vtiful\Kernel\Format::BORDER_THIN,    //
        \Vtiful\Kernel\Format::BORDER_DASHED   //
    )
    ->toResource();

$fileObject->header(['name', 'score'])
    ->setRow('A1', 20, $borderStyle)
    ->output();

Last updated