142 $this->_isStyleXf =
false;
143 $this->_fontIndex = 0;
145 $this->_numberFormatIndex = 0;
147 $this->_text_justlast = 0;
149 $this->_fg_color = 0x40;
150 $this->_bg_color = 0x41;
154 $this->_bottom_color = 0x40;
155 $this->_top_color = 0x40;
156 $this->_left_color = 0x40;
157 $this->_right_color = 0x40;
158 $this->_diag_color = 0x40;
172 if ($this->_isStyleXf) {
180 $atr_num = ($this->_numberFormatIndex != 0)?1:0;
181 $atr_fnt = ($this->_fontIndex != 0)?1:0;
182 $atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0;
187 $atr_pat = (($this->_fg_color != 0x40) ||
188 ($this->_bg_color != 0x41) ||
194 if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
195 $this->_bottom_color = 0;
197 if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
198 $this->_top_color = 0;
200 if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
201 $this->_right_color = 0;
203 if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
204 $this->_left_color = 0;
206 if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
207 $this->_diag_color = 0;
216 $align = $this->
_mapHAlign($this->_style->getAlignment()->getHorizontal());
217 $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
218 $align |=
self::_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
219 $align |= $this->_text_justlast << 7;
221 $used_attrib = $atr_num << 2;
222 $used_attrib |= $atr_fnt << 3;
223 $used_attrib |= $atr_alc << 4;
224 $used_attrib |= $atr_bdr << 5;
225 $used_attrib |= $atr_pat << 6;
226 $used_attrib |= $atr_prot << 7;
229 $icv |= $this->_bg_color << 7;
235 $border1 |= $this->_left_color << 16;
236 $border1 |= $this->_right_color << 23;
238 $diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
243 $border1 |= $diag_tl_to_rb << 30;
244 $border1 |= $diag_tr_to_lb << 31;
247 $border2 |= $this->_bottom_color << 7;
248 $border2 |= $this->_diag_color << 14;
249 $border2 |=
self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
252 $header = pack(
"vv", $record, $length);
255 $biff8_options = $this->_style->getAlignment()->getIndent();
256 $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
258 $data = pack(
"vvvC", $ifnt, $ifmt,
$style, $align);
260 , self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
264 $data .= pack(
"VVv", $border1, $border2, $icv);
276 $this->_isStyleXf = $value;
287 $this->_bottom_color = $colorIndex;
298 $this->_top_color = $colorIndex;
309 $this->_left_color = $colorIndex;
320 $this->_right_color = $colorIndex;
331 $this->_diag_color = $colorIndex;
343 $this->_fg_color = $colorIndex;
354 $this->_bg_color = $colorIndex;
366 $this->_numberFormatIndex = $numberFormatIndex;
376 $this->_fontIndex = $value;
407 if (isset(self::$_mapBorderStyle[$borderStyle]))
408 return self::$_mapBorderStyle[$borderStyle];
446 if (isset(self::$_mapFillType[$fillType]))
447 return self::$_mapFillType[$fillType];
472 if (isset(self::$_mapHAlign[$hAlign]))
473 return self::$_mapHAlign[$hAlign];
494 if (isset(self::$_mapVAlign[$vAlign]))
495 return self::$_mapVAlign[$vAlign];
506 if ($textRotation >= 0) {
507 return $textRotation;
509 if ($textRotation == -165) {
512 if ($textRotation < 0) {
513 return 90 - $textRotation;
An exception for terminatinating execution or to throw for unit testing.
const HORIZONTAL_CENTER_CONTINUOUS
const BORDER_MEDIUMDASHDOTDOT
const BORDER_MEDIUMDASHED
const BORDER_SLANTDASHDOT
const BORDER_MEDIUMDASHDOT
const FILL_PATTERN_LIGHTUP
const FILL_PATTERN_DARKDOWN
const FILL_PATTERN_DARKUP
const FILL_PATTERN_LIGHTVERTICAL
const FILL_PATTERN_LIGHTGRAY
const FILL_PATTERN_LIGHTDOWN
const FILL_PATTERN_DARKGRAY
const FILL_PATTERN_GRAY125
const FILL_PATTERN_LIGHTHORIZONTAL
const FILL_PATTERN_DARKTRELLIS
const FILL_PATTERN_GRAY0625
const FILL_PATTERN_MEDIUMGRAY
const FILL_GRADIENT_LINEAR
const FILL_PATTERN_DARKVERTICAL
const FILL_PATTERN_DARKHORIZONTAL
const FILL_PATTERN_LIGHTGRID
const FILL_PATTERN_LIGHTTRELLIS
const FILL_PATTERN_DARKGRID
const PROTECTION_UNPROTECTED
const PROTECTION_INHERIT
Protection styles.
const PROTECTION_PROTECTED
static _mapVAlign($vAlign)
Map to BIFF2-BIFF8 codes for vertical alignment.
static _mapFillType($fillType)
Map fill type.
setRightColor($colorIndex)
Sets the cell's right border color.
setBgColor($colorIndex)
Sets the cell's background color.
static _mapLocked($locked)
Map locked.
static _mapHidden($hidden)
Map hidden.
static $_mapVAlign
Map of BIFF2-BIFF8 codes for vertical alignment array of int.
setDiagColor($colorIndex)
Sets the cell's diagonal border color.
static $_mapBorderStyle
Map of BIFF2-BIFF8 codes for border styles array of int.
setBottomColor($colorIndex)
Sets the cell's bottom border color.
setNumberFormatIndex($numberFormatIndex)
Sets the index to the number format record It can be date, time, currency, etc...
static $_mapHAlign
Map of BIFF2-BIFF8 codes for horizontal alignment array of int.
static _mapTextRotation($textRotation)
Map to BIFF8 codes for text rotation angle.
writeXf()
Generate an Excel BIFF XF record (style or cell).
__construct(PHPExcel_Style $style=null)
Constructor.
static _mapBorderStyle($borderStyle)
Map border style.
setLeftColor($colorIndex)
Sets the cell's left border color.
_mapHAlign($hAlign)
Map to BIFF2-BIFF8 codes for horizontal alignment.
setIsStyleXf($value)
Is this a style XF ?
setTopColor($colorIndex)
Sets the cell's top border color.
setFontIndex($value)
Set the font index.
setFgColor($colorIndex)
Sets the cell's foreground color.
static $_mapFillType
Map of BIFF2-BIFF8 codes for fill types array of int.