有没有人知道用于将图案样式添加到单元格颜色的语法?我想添加一条薄的反向斜条纹。
答案 0 :(得分:3)
据我所知,这是不可能的。在\Style\Fill.php
中,这些似乎是唯一的选择,尽管可能有更多版本有更多选择。
$worksheet->getStyle('A:C')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
/* Fill types */
const FILL_NONE = 'none';
const FILL_SOLID = 'solid';
const FILL_GRADIENT_LINEAR = 'linear';
const FILL_GRADIENT_PATH = 'path';
const FILL_PATTERN_DARKDOWN = 'darkDown';
const FILL_PATTERN_DARKGRAY = 'darkGray';
const FILL_PATTERN_DARKGRID = 'darkGrid';
const FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal';
const FILL_PATTERN_DARKTRELLIS = 'darkTrellis';
const FILL_PATTERN_DARKUP = 'darkUp';
const FILL_PATTERN_DARKVERTICAL = 'darkVertical';
const FILL_PATTERN_GRAY0625 = 'gray0625';
const FILL_PATTERN_GRAY125 = 'gray125';
const FILL_PATTERN_LIGHTDOWN = 'lightDown';
const FILL_PATTERN_LIGHTGRAY = 'lightGray';
const FILL_PATTERN_LIGHTGRID = 'lightGrid';
const FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal';
const FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis';
const FILL_PATTERN_LIGHTUP = 'lightUp';
const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical';
const FILL_PATTERN_MEDIUMGRAY = 'mediumGray';
答案 1 :(得分:1)
从GDP的水平或垂直答案中选择最合适的模式,设置适当的颜色,然后选择setRotation()作为填充:
$worksheet->getStyle('A1')->getFill()
->setFillType(PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR)
->setStartColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK))
->setEndColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_WHITE))
->setRotation(45);