close

官網文件:

https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#formatting-cells

使用方法:

1. 先設定styleArray

 

$styleArray = array(
        'borders' => array(
            'outline' => array(
                'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
                'color' => array('argb' => 'FFFF0000'),
            ),
        ),
    );

 

2. 將此styleArray設定至目標儲存格:

$sheet ->getStyle('B2:G8')->applyFromArray($styleArray);

--

以下是border的詳細內容

 

just like in the example.

  • On a single cell:
    • left: ->getLeft()
    • right: ->getRight()
    • top: ->getTop()
    • bottom: ->getBottom()
    • diagonal: ->getDiagonal()
  • On an area:
    • allBorders: ->getAllBorders()
    • outline: ->getOutline()
    • inside: ->getInside()
    • vertical: ->getVertical()
    • horizontal: ->getHorizontal()

The patterns visualized (also from the docs):

Available border styles

Border::BORDER_DASHDOT
Border::BORDER_DASHDOTDOT
Border::BORDER_DASHED
Border::BORDER_DOTTED
Border::BORDER_DOUBLE
Border::BORDER_HAIR
Border::BORDER_MEDIUM
Border::BORDER_MEDIUMDASHDOT
Border::BORDER_MEDIUMDASHDOTDOT
Border::BORDER_MEDIUMDASHED
Border::BORDER_NONE
Border::BORDER_SLANTDASHDOT
Border::BORDER_THICK
Border::BORDER_THIN

 

 

--
框線種類中文說明:
PHPExcel 框線種類:
PHPExcel_Style_Border::BORDER_NONE 無框線
PHPExcel_Style_Border::BORDER_HAIR 極細線
PHPExcel_Style_Border::BORDER_THIN 細線
PHPExcel_Style_Border::BORDER_MEDIUM 普通線
PHPExcel_Style_Border::BORDER_THICK 粗線
PHPExcel_Style_Border::BORDER_DOUBLE 二重線
PHPExcel_Style_Border::BORDER_DOTTED 點線(細線)(短,.......)
PHPExcel_Style_Border::BORDER_DASHED 點線(細線)(長,-------)
PHPExcel_Style_Border::BORDER_MEDIUMDASHED 點線(普通線)(長)
PHPExcel_Style_Border::BORDER_DASHDOT 一點鎖線(細線)(-.-.-.-)
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT 一點鎖線(普通線)
PHPExcel_Style_Border::BORDER_DASHDOTDOT 二點鎖線(細線)(-..-..-..-)
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT 二點鎖線(普通線)
PHPExcel_Style_Border::BORDER_SLANTDASHDOT 斜邊一點鎖線
--

 

參考

https://stackoverflow.com/questions/46959282/styling-cell-borders-with-phpspreadsheet-php/47035139#47035139

https://www.facebook.com/pja2016/posts/225170664250875/

 

--

--

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dizzy03 的頭像
    dizzy03

    碎碎念

    dizzy03 發表在 痞客邦 留言(0) 人氣()