ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_Writer_Excel5_Xf Class Reference
+ Collaboration diagram for PHPExcel_Writer_Excel5_Xf:

Public Member Functions

 __construct (PHPExcel_Style $style=null)
 Constructor. More...
 
 writeXf ()
 Generate an Excel BIFF XF record (style or cell). More...
 
 setIsStyleXf ($value)
 Is this a style XF ? More...
 
 setBottomColor ($colorIndex)
 Sets the cell's bottom border color. More...
 
 setTopColor ($colorIndex)
 Sets the cell's top border color. More...
 
 setLeftColor ($colorIndex)
 Sets the cell's left border color. More...
 
 setRightColor ($colorIndex)
 Sets the cell's right border color. More...
 
 setDiagColor ($colorIndex)
 Sets the cell's diagonal border color. More...
 
 setFgColor ($colorIndex)
 Sets the cell's foreground color. More...
 
 setBgColor ($colorIndex)
 Sets the cell's background color. More...
 
 setNumberFormatIndex ($numberFormatIndex)
 Sets the index to the number format record It can be date, time, currency, etc... More...
 
 setFontIndex ($value)
 Set the font index. More...
 

Data Fields

 $_numberFormatIndex
 
 $_text_justlast
 
 $_fg_color
 
 $_bg_color
 
 $_bottom_color
 
 $_top_color
 
 $_left_color
 
 $_right_color
 

Private Member Functions

 _mapHAlign ($hAlign)
 Map to BIFF2-BIFF8 codes for horizontal alignment. More...
 

Static Private Member Functions

static _mapBorderStyle ($borderStyle)
 Map border style. More...
 
static _mapFillType ($fillType)
 Map fill type. More...
 
static _mapVAlign ($vAlign)
 Map to BIFF2-BIFF8 codes for vertical alignment. More...
 
static _mapTextRotation ($textRotation)
 Map to BIFF8 codes for text rotation angle. More...
 
static _mapLocked ($locked)
 Map locked. More...
 
static _mapHidden ($hidden)
 Map hidden. More...
 

Private Attributes

 $_isStyleXf
 
 $_fontIndex
 

Static Private Attributes

static $_mapBorderStyle
 Map of BIFF2-BIFF8 codes for border styles. More...
 
static $_mapFillType
 Map of BIFF2-BIFF8 codes for fill types. More...
 
static $_mapHAlign
 Map of BIFF2-BIFF8 codes for horizontal alignment. More...
 
static $_mapVAlign
 Map of BIFF2-BIFF8 codes for vertical alignment. More...
 

Detailed Description

Definition at line 71 of file Xf.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_Writer_Excel5_Xf::__construct ( PHPExcel_Style  $style = null)

Constructor.

public

Parameters
PHPExcel_StyleThe XF format

Definition at line 140 of file Xf.php.

References $style.

141  {
142  $this->_isStyleXf = false;
143  $this->_fontIndex = 0;
144 
145  $this->_numberFormatIndex = 0;
146 
147  $this->_text_justlast = 0;
148 
149  $this->_fg_color = 0x40;
150  $this->_bg_color = 0x41;
151 
152  $this->_diag = 0;
153 
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;
159  $this->_style = $style;
160 
161  }
$style
Definition: example_012.php:70

Member Function Documentation

◆ _mapBorderStyle()

static PHPExcel_Writer_Excel5_Xf::_mapBorderStyle (   $borderStyle)
staticprivate

Map border style.

Parameters
string$borderStyle
Returns
int

Definition at line 406 of file Xf.php.

406  {
407  if (isset(self::$_mapBorderStyle[$borderStyle]))
408  return self::$_mapBorderStyle[$borderStyle];
409  return 0x00;
410  }

◆ _mapFillType()

static PHPExcel_Writer_Excel5_Xf::_mapFillType (   $fillType)
staticprivate

Map fill type.

Parameters
string$fillType
Returns
int

Definition at line 445 of file Xf.php.

445  {
446  if (isset(self::$_mapFillType[$fillType]))
447  return self::$_mapFillType[$fillType];
448  return 0x00;
449  }

◆ _mapHAlign()

PHPExcel_Writer_Excel5_Xf::_mapHAlign (   $hAlign)
private

Map to BIFF2-BIFF8 codes for horizontal alignment.

Parameters
string$hAlign
Returns
int

Definition at line 470 of file Xf.php.

Referenced by writeXf().

471  {
472  if (isset(self::$_mapHAlign[$hAlign]))
473  return self::$_mapHAlign[$hAlign];
474  return 0;
475  }
+ Here is the caller graph for this function:

◆ _mapHidden()

static PHPExcel_Writer_Excel5_Xf::_mapHidden (   $hidden)
staticprivate

Map hidden.

Parameters
string
Returns
int

Definition at line 538 of file Xf.php.

References PHPExcel_Style_Protection\PROTECTION_INHERIT, PHPExcel_Style_Protection\PROTECTION_PROTECTED, and PHPExcel_Style_Protection\PROTECTION_UNPROTECTED.

538  {
539  switch ($hidden) {
543  default: return 0;
544  }
545  }
const PROTECTION_INHERIT
Protection styles.
Definition: Protection.php:39

◆ _mapLocked()

static PHPExcel_Writer_Excel5_Xf::_mapLocked (   $locked)
staticprivate

Map locked.

Parameters
string
Returns
int

Definition at line 523 of file Xf.php.

References PHPExcel_Style_Protection\PROTECTION_INHERIT, PHPExcel_Style_Protection\PROTECTION_PROTECTED, and PHPExcel_Style_Protection\PROTECTION_UNPROTECTED.

523  {
524  switch ($locked) {
528  default: return 1;
529  }
530  }
const PROTECTION_INHERIT
Protection styles.
Definition: Protection.php:39

◆ _mapTextRotation()

static PHPExcel_Writer_Excel5_Xf::_mapTextRotation (   $textRotation)
staticprivate

Map to BIFF8 codes for text rotation angle.

Parameters
int$textRotation
Returns
int

Definition at line 505 of file Xf.php.

505  {
506  if ($textRotation >= 0) {
507  return $textRotation;
508  }
509  if ($textRotation == -165) {
510  return 255;
511  }
512  if ($textRotation < 0) {
513  return 90 - $textRotation;
514  }
515  }

◆ _mapVAlign()

static PHPExcel_Writer_Excel5_Xf::_mapVAlign (   $vAlign)
staticprivate

Map to BIFF2-BIFF8 codes for vertical alignment.

Parameters
string$vAlign
Returns
int

Definition at line 493 of file Xf.php.

493  {
494  if (isset(self::$_mapVAlign[$vAlign]))
495  return self::$_mapVAlign[$vAlign];
496  return 2;
497  }

◆ setBgColor()

PHPExcel_Writer_Excel5_Xf::setBgColor (   $colorIndex)

Sets the cell's background color.

public

Parameters
int$colorIndexColor index

Definition at line 352 of file Xf.php.

353  {
354  $this->_bg_color = $colorIndex;
355  }

◆ setBottomColor()

PHPExcel_Writer_Excel5_Xf::setBottomColor (   $colorIndex)

Sets the cell's bottom border color.

public

Parameters
int$colorIndexColor index

Definition at line 285 of file Xf.php.

286  {
287  $this->_bottom_color = $colorIndex;
288  }

◆ setDiagColor()

PHPExcel_Writer_Excel5_Xf::setDiagColor (   $colorIndex)

Sets the cell's diagonal border color.

public

Parameters
int$colorIndexColor index

Definition at line 329 of file Xf.php.

330  {
331  $this->_diag_color = $colorIndex;
332  }

◆ setFgColor()

PHPExcel_Writer_Excel5_Xf::setFgColor (   $colorIndex)

Sets the cell's foreground color.

public

Parameters
int$colorIndexColor index

Definition at line 341 of file Xf.php.

342  {
343  $this->_fg_color = $colorIndex;
344  }

◆ setFontIndex()

PHPExcel_Writer_Excel5_Xf::setFontIndex (   $value)

Set the font index.

Parameters
int$valueFont index, note that value 4 does not exist

Definition at line 374 of file Xf.php.

375  {
376  $this->_fontIndex = $value;
377  }

◆ setIsStyleXf()

PHPExcel_Writer_Excel5_Xf::setIsStyleXf (   $value)

Is this a style XF ?

Parameters
boolean$value

Definition at line 274 of file Xf.php.

275  {
276  $this->_isStyleXf = $value;
277  }

◆ setLeftColor()

PHPExcel_Writer_Excel5_Xf::setLeftColor (   $colorIndex)

Sets the cell's left border color.

public

Parameters
int$colorIndexColor index

Definition at line 307 of file Xf.php.

308  {
309  $this->_left_color = $colorIndex;
310  }

◆ setNumberFormatIndex()

PHPExcel_Writer_Excel5_Xf::setNumberFormatIndex (   $numberFormatIndex)

Sets the index to the number format record It can be date, time, currency, etc...

public

Parameters
integer$numberFormatIndexIndex to format record

Definition at line 364 of file Xf.php.

365  {
366  $this->_numberFormatIndex = $numberFormatIndex;
367  }

◆ setRightColor()

PHPExcel_Writer_Excel5_Xf::setRightColor (   $colorIndex)

Sets the cell's right border color.

public

Parameters
int$colorIndexColor index

Definition at line 318 of file Xf.php.

319  {
320  $this->_right_color = $colorIndex;
321  }

◆ setTopColor()

PHPExcel_Writer_Excel5_Xf::setTopColor (   $colorIndex)

Sets the cell's top border color.

public

Parameters
int$colorIndexColor index

Definition at line 296 of file Xf.php.

297  {
298  $this->_top_color = $colorIndex;
299  }

◆ writeXf()

PHPExcel_Writer_Excel5_Xf::writeXf ( )

Generate an Excel BIFF XF record (style or cell).

Returns
string The XF record

Definition at line 169 of file Xf.php.

References $_fg_color, $_fontIndex, $_numberFormatIndex, $_top_color, $data, $header, $style, _mapHAlign(), PHPExcel_Style_Borders\DIAGONAL_BOTH, PHPExcel_Style_Borders\DIAGONAL_DOWN, and PHPExcel_Style_Borders\DIAGONAL_UP.

170  {
171  // Set the type of the XF record and some of the attributes.
172  if ($this->_isStyleXf) {
173  $style = 0xFFF5;
174  } else {
175  $style = self::_mapLocked($this->_style->getProtection()->getLocked());
176  $style |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1;
177  }
178 
179  // Flags to indicate if attributes have been set.
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());
192 
193  // Zero the default border colour if the border has not been set.
194  if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
195  $this->_bottom_color = 0;
196  }
197  if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
198  $this->_top_color = 0;
199  }
200  if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
201  $this->_right_color = 0;
202  }
203  if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
204  $this->_left_color = 0;
205  }
206  if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
207  $this->_diag_color = 0;
208  }
209 
210  $record = 0x00E0; // Record identifier
211  $length = 0x0014; // Number of bytes to follow
212 
213  $ifnt = $this->_fontIndex; // Index to FONT record
214  $ifmt = $this->_numberFormatIndex; // Index to FORMAT record
215 
216  $align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
217  $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
218  $align |= self::_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
219  $align |= $this->_text_justlast << 7;
220 
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;
227 
228  $icv = $this->_fg_color; // fg and bg pattern colors
229  $icv |= $this->_bg_color << 7;
230 
231  $border1 = self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
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;
237 
238  $diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
239  $diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
240  || $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
241  $diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
242  || $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
243  $border1 |= $diag_tl_to_rb << 30;
244  $border1 |= $diag_tr_to_lb << 31;
245 
246  $border2 = $this->_top_color; // Border color
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;
251 
252  $header = pack("vv", $record, $length);
253 
254  //BIFF8 options: identation, shrinkToFit and text direction
255  $biff8_options = $this->_style->getAlignment()->getIndent();
256  $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
257 
258  $data = pack("vvvC", $ifnt, $ifmt, $style, $align);
259  $data .= pack("CCC"
260  , self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
261  , $biff8_options
262  , $used_attrib
263  );
264  $data .= pack("VVv", $border1, $border2, $icv);
265 
266  return($header . $data);
267  }
$style
Definition: example_012.php:70
$header
_mapHAlign($hAlign)
Map to BIFF2-BIFF8 codes for horizontal alignment.
Definition: Xf.php:470
+ Here is the call graph for this function:

Field Documentation

◆ $_bg_color

PHPExcel_Writer_Excel5_Xf::$_bg_color

Definition at line 108 of file Xf.php.

◆ $_bottom_color

PHPExcel_Writer_Excel5_Xf::$_bottom_color

Definition at line 114 of file Xf.php.

◆ $_fg_color

PHPExcel_Writer_Excel5_Xf::$_fg_color

Definition at line 102 of file Xf.php.

Referenced by writeXf().

◆ $_fontIndex

PHPExcel_Writer_Excel5_Xf::$_fontIndex
private

Definition at line 84 of file Xf.php.

Referenced by writeXf().

◆ $_isStyleXf

PHPExcel_Writer_Excel5_Xf::$_isStyleXf
private

Definition at line 78 of file Xf.php.

◆ $_left_color

PHPExcel_Writer_Excel5_Xf::$_left_color

Definition at line 126 of file Xf.php.

◆ $_mapBorderStyle

◆ $_mapFillType

◆ $_mapHAlign

PHPExcel_Writer_Excel5_Xf::$_mapHAlign
staticprivate

◆ $_mapVAlign

PHPExcel_Writer_Excel5_Xf::$_mapVAlign
staticprivate
Initial value:

Map of BIFF2-BIFF8 codes for vertical alignment.

array of int

Definition at line 482 of file Xf.php.

◆ $_numberFormatIndex

PHPExcel_Writer_Excel5_Xf::$_numberFormatIndex

Definition at line 90 of file Xf.php.

Referenced by writeXf().

◆ $_right_color

PHPExcel_Writer_Excel5_Xf::$_right_color

Definition at line 132 of file Xf.php.

◆ $_text_justlast

PHPExcel_Writer_Excel5_Xf::$_text_justlast

Definition at line 96 of file Xf.php.

◆ $_top_color

PHPExcel_Writer_Excel5_Xf::$_top_color

Definition at line 120 of file Xf.php.

Referenced by writeXf().


The documentation for this class was generated from the following file: