Created
January 4, 2016 13:39
-
-
Save ctrl-f5/e2ae65c4e87b3c1a54f5 to your computer and use it in GitHub Desktop.
PHPOffice/PHPExcel cell styling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$excel = new \PHPExcel(); | |
$sheet = $excel->getActiveSheet(); | |
$sheet->getCell('A1')->setValue('test'); | |
$style = new \PHPExcel_Style(); | |
$style | |
->getFill() | |
->setStartColor(new \PHPExcel_Style_Color(\PHPExcel_Style_Color::COLOR_RED)) | |
->setEndColor(new \PHPExcel_Style_Color(\PHPExcel_Style_Color::COLOR_RED)) | |
->setFillType(\PHPExcel_Style_Fill::FILL_SOLID) | |
; | |
$style | |
->getFont() | |
->setBold(true) | |
->setColor(new \PHPExcel_Style_Color(\PHPExcel_Style_Color::COLOR_YELLOW)) | |
->setItalic(true) | |
->setUnderline(true) | |
->setSize(20); | |
$sheet->duplicateStyle($style, 'A1'); | |
$writer = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); | |
$writer->save('/tmp/test.xlsx'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment