2

有谁知道用于将图案样式添加到单元格颜色的语法?我想添加一条细的反向斜条纹。

4

2 回答 2

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';
于 2012-06-29T19:05:25.173 回答
1

从 GDP 答案中列出的水平或垂直模式中选择最合适的模式,设置适当的颜色,然后为填充设置旋转():

$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);
于 2012-07-01T18:01:13.857 回答