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) {
175 $style = self::_mapLocked($this->_style->getProtection()->getLocked());
176 $style |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1;
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;
183 $atr_bdr = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
184 self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
185 self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
186 self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
187 $atr_pat = (($this->_fg_color != 0x40) ||
188 ($this->_bg_color != 0x41) ||
189 self::_mapFillType($this->_style->getFill()->getFillType()))?1:0;
190 $atr_prot = self::_mapLocked($this->_style->getProtection()->getLocked())
191 | self::_mapHidden($this->_style->getProtection()->getHidden());
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;
231 $border1 = self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle());
232 $border1 |= self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
233 $border1 |= self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
234 $border1 |= self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
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;
250 $border2 |= self::_mapFillType($this->_style->getFill()->getFillType()) << 26;
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);
266 return($header .
$data);
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;
static _mapLocked($locked)
Map locked.
const FILL_PATTERN_LIGHTHORIZONTAL
const FILL_PATTERN_LIGHTGRAY
setFgColor($colorIndex)
Sets the cell's foreground color.
const FILL_PATTERN_DARKGRID
setRightColor($colorIndex)
Sets the cell's right border color.
const FILL_PATTERN_DARKHORIZONTAL
const BORDER_MEDIUMDASHDOT
writeXf()
Generate an Excel BIFF XF record (style or cell).
setBottomColor($colorIndex)
Sets the cell's bottom border color.
static _mapFillType($fillType)
Map fill type.
setIsStyleXf($value)
Is this a style XF ?
const FILL_PATTERN_LIGHTTRELLIS
static $_mapBorderStyle
Map of BIFF2-BIFF8 codes for border styles.
static $_mapVAlign
Map of BIFF2-BIFF8 codes for vertical alignment.
const PROTECTION_UNPROTECTED
setDiagColor($colorIndex)
Sets the cell's diagonal border color.
static $_mapFillType
Map of BIFF2-BIFF8 codes for fill types.
const HORIZONTAL_CENTER_CONTINUOUS
const FILL_PATTERN_LIGHTDOWN
static $_mapHAlign
Map of BIFF2-BIFF8 codes for horizontal alignment.
static _mapTextRotation($textRotation)
Map to BIFF8 codes for text rotation angle.
const FILL_PATTERN_MEDIUMGRAY
const PROTECTION_INHERIT
Protection styles.
static _mapHidden($hidden)
Map hidden.
const FILL_PATTERN_DARKDOWN
const FILL_PATTERN_GRAY125
const FILL_PATTERN_DARKTRELLIS
const FILL_PATTERN_LIGHTVERTICAL
const BORDER_MEDIUMDASHDOTDOT
Create styles array
The data for the language used.
const PROTECTION_PROTECTED
const FILL_PATTERN_GRAY0625
setTopColor($colorIndex)
Sets the cell's top border color.
const FILL_PATTERN_LIGHTGRID
__construct(PHPExcel_Style $style=null)
Constructor.
const BORDER_SLANTDASHDOT
const FILL_PATTERN_DARKVERTICAL
static _mapBorderStyle($borderStyle)
Map border style.
const FILL_PATTERN_DARKGRAY
setLeftColor($colorIndex)
Sets the cell's left border color.
const FILL_PATTERN_LIGHTUP
setFontIndex($value)
Set the font index.
const FILL_PATTERN_DARKUP
const BORDER_MEDIUMDASHED
setNumberFormatIndex($numberFormatIndex)
Sets the index to the number format record It can be date, time, currency, etc... ...
static _mapVAlign($vAlign)
Map to BIFF2-BIFF8 codes for vertical alignment.
setBgColor($colorIndex)
Sets the cell's background color.
_mapHAlign($hAlign)
Map to BIFF2-BIFF8 codes for horizontal alignment.
const FILL_GRADIENT_LINEAR