ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PHPExcel_Writer_Excel2007_Style Class Reference
+ Inheritance diagram for PHPExcel_Writer_Excel2007_Style:
+ Collaboration diagram for PHPExcel_Writer_Excel2007_Style:

Public Member Functions

 writeStyles (PHPExcel $pPHPExcel=null)
 Write styles to XML format. More...
 
 allStyles (PHPExcel $pPHPExcel=null)
 Get an array of all styles. More...
 
 allConditionalStyles (PHPExcel $pPHPExcel=null)
 Get an array of all conditional styles. More...
 
 allFills (PHPExcel $pPHPExcel=null)
 Get an array of all fills. More...
 
 allFonts (PHPExcel $pPHPExcel=null)
 Get an array of all fonts. More...
 
 allBorders (PHPExcel $pPHPExcel=null)
 Get an array of all borders. More...
 
 allNumberFormats (PHPExcel $pPHPExcel=null)
 Get an array of all number formats. More...
 
- Public Member Functions inherited from PHPExcel_Writer_Excel2007_WriterPart
 setParentWriter (PHPExcel_Writer_IWriter $pWriter=null)
 Set parent IWriter object. More...
 
 getParentWriter ()
 Get parent IWriter object. More...
 
 __construct (PHPExcel_Writer_IWriter $pWriter=null)
 Set parent IWriter object. More...
 

Private Member Functions

 _writeFill (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Fill $pFill=null)
 Write Fill. More...
 
 _writeGradientFill (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Fill $pFill=null)
 Write Gradient Fill. More...
 
 _writePatternFill (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Fill $pFill=null)
 Write Pattern Fill. More...
 
 _writeFont (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Font $pFont=null)
 Write Font. More...
 
 _writeBorder (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Borders $pBorders=null)
 Write Border. More...
 
 _writeCellStyleXf (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style $pStyle=null, PHPExcel $pPHPExcel=null)
 Write Cell Style Xf. More...
 
 _writeCellStyleDxf (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style $pStyle=null)
 Write Cell Style Dxf. More...
 
 _writeBorderPr (PHPExcel_Shared_XMLWriter $objWriter=null, $pName='left', PHPExcel_Style_Border $pBorder=null)
 Write BorderPr. More...
 
 _writeNumFmt (PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_NumberFormat $pNumberFormat=null, $pId=0)
 Write NumberFormat. More...
 

Detailed Description

Definition at line 36 of file Style.php.

Member Function Documentation

◆ _writeBorder()

PHPExcel_Writer_Excel2007_Style::_writeBorder ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style_Borders  $pBorders = null 
)
private

Write Border.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style_Borders$pBordersBorders style
Exceptions
PHPExcel_Writer_Exception

Definition at line 357 of file Style.php.

References $objWriter, _writeBorderPr(), PHPExcel_Style_Borders\DIAGONAL_BOTH, PHPExcel_Style_Borders\DIAGONAL_DOWN, and PHPExcel_Style_Borders\DIAGONAL_UP.

Referenced by _writeCellStyleDxf(), and writeStyles().

358  {
359  // Write border
360  $objWriter->startElement('border');
361  // Diagonal?
362  switch ($pBorders->getDiagonalDirection()) {
364  $objWriter->writeAttribute('diagonalUp', 'true');
365  $objWriter->writeAttribute('diagonalDown', 'false');
366  break;
368  $objWriter->writeAttribute('diagonalUp', 'false');
369  $objWriter->writeAttribute('diagonalDown', 'true');
370  break;
372  $objWriter->writeAttribute('diagonalUp', 'true');
373  $objWriter->writeAttribute('diagonalDown', 'true');
374  break;
375  }
376 
377  // BorderPr
378  $this->_writeBorderPr($objWriter, 'left', $pBorders->getLeft());
379  $this->_writeBorderPr($objWriter, 'right', $pBorders->getRight());
380  $this->_writeBorderPr($objWriter, 'top', $pBorders->getTop());
381  $this->_writeBorderPr($objWriter, 'bottom', $pBorders->getBottom());
382  $this->_writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal());
383  $objWriter->endElement();
384  }
getBottom()
Get Bottom.
Definition: Borders.php:295
getDiagonal()
Get Diagonal.
Definition: Borders.php:304
_writeBorderPr(PHPExcel_Shared_XMLWriter $objWriter=null, $pName='left', PHPExcel_Style_Border $pBorder=null)
Write BorderPr.
Definition: Style.php:535
getLeft()
Get Left.
Definition: Borders.php:268
getDiagonalDirection()
Get DiagonalDirection.
Definition: Borders.php:378
getRight()
Get Right.
Definition: Borders.php:277
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeBorderPr()

PHPExcel_Writer_Excel2007_Style::_writeBorderPr ( PHPExcel_Shared_XMLWriter  $objWriter = null,
  $pName = 'left',
PHPExcel_Style_Border  $pBorder = null 
)
private

Write BorderPr.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
string$pNameElement name
PHPExcel_Style_Border$pBorderBorder style
Exceptions
PHPExcel_Writer_Exception

Definition at line 535 of file Style.php.

References $objWriter, and PHPExcel_Style_Border\BORDER_NONE.

Referenced by _writeBorder().

536  {
537  // Write BorderPr
539  $objWriter->startElement($pName);
540  $objWriter->writeAttribute('style', $pBorder->getBorderStyle());
541 
542  // color
543  $objWriter->startElement('color');
544  $objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB());
545  $objWriter->endElement();
546 
547  $objWriter->endElement();
548  }
549  }
getColor()
Get Border Color.
Definition: Border.php:254
getBorderStyle()
Get Border style.
Definition: Border.php:218
+ Here is the caller graph for this function:

◆ _writeCellStyleDxf()

PHPExcel_Writer_Excel2007_Style::_writeCellStyleDxf ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style  $pStyle = null 
)
private

Write Cell Style Dxf.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style$pStyleStyle
Exceptions
PHPExcel_Writer_Exception

Definition at line 469 of file Style.php.

References $objWriter, _writeBorder(), _writeFill(), _writeFont(), _writeNumFmt(), PHPExcel_Style_Protection\PROTECTION_INHERIT, and PHPExcel_Style_Protection\PROTECTION_PROTECTED.

Referenced by writeStyles().

470  {
471  // dxf
472  $objWriter->startElement('dxf');
473 
474  // font
475  $this->_writeFont($objWriter, $pStyle->getFont());
476 
477  // numFmt
478  $this->_writeNumFmt($objWriter, $pStyle->getNumberFormat());
479 
480  // fill
481  $this->_writeFill($objWriter, $pStyle->getFill());
482 
483  // alignment
484  $objWriter->startElement('alignment');
485  if ($pStyle->getAlignment()->getHorizontal() !== NULL) {
486  $objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
487  }
488  if ($pStyle->getAlignment()->getVertical() !== NULL) {
489  $objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
490  }
491 
492  if ($pStyle->getAlignment()->getTextRotation() !== NULL) {
493  $textRotation = 0;
494  if ($pStyle->getAlignment()->getTextRotation() >= 0) {
495  $textRotation = $pStyle->getAlignment()->getTextRotation();
496  } else if ($pStyle->getAlignment()->getTextRotation() < 0) {
497  $textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
498  }
499  $objWriter->writeAttribute('textRotation', $textRotation);
500  }
501  $objWriter->endElement();
502 
503  // border
504  $this->_writeBorder($objWriter, $pStyle->getBorders());
505 
506  // protection
507  if (($pStyle->getProtection()->getLocked() !== NULL) ||
508  ($pStyle->getProtection()->getHidden() !== NULL)) {
509  if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
510  $pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
511  $objWriter->startElement('protection');
512  if (($pStyle->getProtection()->getLocked() !== NULL) &&
513  ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
514  $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
515  }
516  if (($pStyle->getProtection()->getHidden() !== NULL) &&
517  ($pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
518  $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
519  }
520  $objWriter->endElement();
521  }
522  }
523 
524  $objWriter->endElement();
525  }
getProtection()
Get Protection.
Definition: Style.php:586
getBorders()
Get Borders.
Definition: Style.php:532
_writeFill(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Fill $pFill=null)
Write Fill.
Definition: Style.php:175
const PROTECTION_INHERIT
Protection styles.
Definition: Protection.php:39
_writeFont(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Font $pFont=null)
Write Font.
Definition: Style.php:277
getAlignment()
Get Alignment.
Definition: Style.php:542
getFill()
Get Fill.
Definition: Style.php:500
_writeNumFmt(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_NumberFormat $pNumberFormat=null, $pId=0)
Write NumberFormat.
Definition: Style.php:559
getNumberFormat()
Get Number Format.
Definition: Style.php:552
_writeBorder(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Borders $pBorders=null)
Write Border.
Definition: Style.php:357
getFont()
Get Font.
Definition: Style.php:510
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeCellStyleXf()

PHPExcel_Writer_Excel2007_Style::_writeCellStyleXf ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style  $pStyle = null,
PHPExcel  $pPHPExcel = null 
)
private

Write Cell Style Xf.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style$pStyleStyle
PHPExcel$pPHPExcelWorkbook
Exceptions
PHPExcel_Writer_Exception

Definition at line 394 of file Style.php.

References $objWriter, PHPExcel_Writer_Excel2007_WriterPart\getParentWriter(), PHPExcel_Style_Protection\PROTECTION_INHERIT, and PHPExcel_Style_Protection\PROTECTION_PROTECTED.

Referenced by writeStyles().

395  {
396  // xf
397  $objWriter->startElement('xf');
398  $objWriter->writeAttribute('xfId', 0);
399  $objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
400  if ($pStyle->getQuotePrefix()) {
401  $objWriter->writeAttribute('quotePrefix', 1);
402  }
403 
404  if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
405  $objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
406  } else {
407  $objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
408  }
409 
410  $objWriter->writeAttribute('fillId', (int)$this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
411  $objWriter->writeAttribute('borderId', (int)$this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
412 
413  // Apply styles?
414  $objWriter->writeAttribute('applyFont', ($pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ? '1' : '0');
415  $objWriter->writeAttribute('applyNumberFormat', ($pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ? '1' : '0');
416  $objWriter->writeAttribute('applyFill', ($pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0');
417  $objWriter->writeAttribute('applyBorder', ($pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0');
418  $objWriter->writeAttribute('applyAlignment', ($pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0');
420  $objWriter->writeAttribute('applyProtection', 'true');
421  }
422 
423  // alignment
424  $objWriter->startElement('alignment');
425  $objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
426  $objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
427 
428  $textRotation = 0;
429  if ($pStyle->getAlignment()->getTextRotation() >= 0) {
430  $textRotation = $pStyle->getAlignment()->getTextRotation();
431  } else if ($pStyle->getAlignment()->getTextRotation() < 0) {
432  $textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
433  }
434  $objWriter->writeAttribute('textRotation', $textRotation);
435 
436  $objWriter->writeAttribute('wrapText', ($pStyle->getAlignment()->getWrapText() ? 'true' : 'false'));
437  $objWriter->writeAttribute('shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
438 
439  if ($pStyle->getAlignment()->getIndent() > 0) {
440  $objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
441  }
442  if ($pStyle->getAlignment()->getReadorder() > 0) {
443  $objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder());
444  }
445  $objWriter->endElement();
446 
447  // protection
449  $objWriter->startElement('protection');
450  if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
451  $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
452  }
453  if ($pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
454  $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
455  }
456  $objWriter->endElement();
457  }
458 
459  $objWriter->endElement();
460  }
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
getProtection()
Get Protection.
Definition: Style.php:586
getBorders()
Get Borders.
Definition: Style.php:532
getQuotePrefix()
Get quote prefix.
Definition: Style.php:596
const PROTECTION_INHERIT
Protection styles.
Definition: Protection.php:39
getAlignment()
Get Alignment.
Definition: Style.php:542
getFill()
Get Fill.
Definition: Style.php:500
getNumberFormat()
Get Number Format.
Definition: Style.php:552
getDefaultStyle()
Get default style.
Definition: PHPExcel.php:925
getFont()
Get Font.
Definition: Style.php:510
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeFill()

PHPExcel_Writer_Excel2007_Style::_writeFill ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style_Fill  $pFill = null 
)
private

Write Fill.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style_Fill$pFillFill style
Exceptions
PHPExcel_Writer_Exception

Definition at line 175 of file Style.php.

References $objWriter, _writeGradientFill(), _writePatternFill(), PHPExcel_Style_Fill\FILL_GRADIENT_LINEAR, and PHPExcel_Style_Fill\FILL_GRADIENT_PATH.

Referenced by _writeCellStyleDxf(), and writeStyles().

176  {
177  // Check if this is a pattern type or gradient type
180  // Gradient fill
181  $this->_writeGradientFill($objWriter, $pFill);
182  } elseif($pFill->getFillType() !== NULL) {
183  // Pattern fill
184  $this->_writePatternFill($objWriter, $pFill);
185  }
186  }
_writePatternFill(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Fill $pFill=null)
Write Pattern Fill.
Definition: Style.php:239
const FILL_GRADIENT_PATH
Definition: Fill.php:42
getFillType()
Get Fill Type.
Definition: Fill.php:194
_writeGradientFill(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Fill $pFill=null)
Write Gradient Fill.
Definition: Style.php:195
const FILL_GRADIENT_LINEAR
Definition: Fill.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _writeFont()

PHPExcel_Writer_Excel2007_Style::_writeFont ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style_Font  $pFont = null 
)
private

Write Font.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style_Font$pFontFont style
Exceptions
PHPExcel_Writer_Exception

Definition at line 277 of file Style.php.

References $objWriter.

Referenced by _writeCellStyleDxf(), and writeStyles().

278  {
279  // font
280  $objWriter->startElement('font');
281  // Weird! The order of these elements actually makes a difference when opening Excel2007
282  // files in Excel2003 with the compatibility pack. It's not documented behaviour,
283  // and makes for a real WTF!
284 
285  // Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
286  // for conditional formatting). Otherwise it will apparently not be picked up in conditional
287  // formatting style dialog
288  if ($pFont->getBold() !== NULL) {
289  $objWriter->startElement('b');
290  $objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
291  $objWriter->endElement();
292  }
293 
294  // Italic
295  if ($pFont->getItalic() !== NULL) {
296  $objWriter->startElement('i');
297  $objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
298  $objWriter->endElement();
299  }
300 
301  // Strikethrough
302  if ($pFont->getStrikethrough() !== NULL) {
303  $objWriter->startElement('strike');
304  $objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
305  $objWriter->endElement();
306  }
307 
308  // Underline
309  if ($pFont->getUnderline() !== NULL) {
310  $objWriter->startElement('u');
311  $objWriter->writeAttribute('val', $pFont->getUnderline());
312  $objWriter->endElement();
313  }
314 
315  // Superscript / subscript
316  if ($pFont->getSuperScript() === TRUE || $pFont->getSubScript() === TRUE) {
317  $objWriter->startElement('vertAlign');
318  if ($pFont->getSuperScript() === TRUE) {
319  $objWriter->writeAttribute('val', 'superscript');
320  } else if ($pFont->getSubScript() === TRUE) {
321  $objWriter->writeAttribute('val', 'subscript');
322  }
323  $objWriter->endElement();
324  }
325 
326  // Size
327  if ($pFont->getSize() !== NULL) {
328  $objWriter->startElement('sz');
329  $objWriter->writeAttribute('val', $pFont->getSize());
330  $objWriter->endElement();
331  }
332 
333  // Foreground color
334  if ($pFont->getColor()->getARGB() !== NULL) {
335  $objWriter->startElement('color');
336  $objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
337  $objWriter->endElement();
338  }
339 
340  // Name
341  if ($pFont->getName() !== NULL) {
342  $objWriter->startElement('name');
343  $objWriter->writeAttribute('val', $pFont->getName());
344  $objWriter->endElement();
345  }
346 
347  $objWriter->endElement();
348  }
getName()
Get Name.
Definition: Font.php:231
getUnderline()
Get Underline.
Definition: Font.php:419
getSuperScript()
Get SuperScript.
Definition: Font.php:355
getColor()
Get Color.
Definition: Font.php:485
getSize()
Get Size.
Definition: Font.php:262
getStrikethrough()
Get Strikethrough.
Definition: Font.php:454
getItalic()
Get Italic.
Definition: Font.php:324
getBold()
Get Bold.
Definition: Font.php:293
getSubScript()
Get SubScript.
Definition: Font.php:387
+ Here is the caller graph for this function:

◆ _writeGradientFill()

PHPExcel_Writer_Excel2007_Style::_writeGradientFill ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style_Fill  $pFill = null 
)
private

Write Gradient Fill.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style_Fill$pFillFill style
Exceptions
PHPExcel_Writer_Exception

Definition at line 195 of file Style.php.

References $objWriter.

Referenced by _writeFill().

196  {
197  // fill
198  $objWriter->startElement('fill');
199 
200  // gradientFill
201  $objWriter->startElement('gradientFill');
202  $objWriter->writeAttribute('type', $pFill->getFillType());
203  $objWriter->writeAttribute('degree', $pFill->getRotation());
204 
205  // stop
206  $objWriter->startElement('stop');
207  $objWriter->writeAttribute('position', '0');
208 
209  // color
210  $objWriter->startElement('color');
211  $objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
212  $objWriter->endElement();
213 
214  $objWriter->endElement();
215 
216  // stop
217  $objWriter->startElement('stop');
218  $objWriter->writeAttribute('position', '1');
219 
220  // color
221  $objWriter->startElement('color');
222  $objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
223  $objWriter->endElement();
224 
225  $objWriter->endElement();
226 
227  $objWriter->endElement();
228 
229  $objWriter->endElement();
230  }
getStartColor()
Get Start Color.
Definition: Fill.php:250
getRotation()
Get Rotation.
Definition: Fill.php:222
getEndColor()
Get End Color.
Definition: Fill.php:279
getFillType()
Get Fill Type.
Definition: Fill.php:194
+ Here is the caller graph for this function:

◆ _writeNumFmt()

PHPExcel_Writer_Excel2007_Style::_writeNumFmt ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style_NumberFormat  $pNumberFormat = null,
  $pId = 0 
)
private

Write NumberFormat.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style_NumberFormat$pNumberFormatNumber Format
int$pIdNumber Format identifier
Exceptions
PHPExcel_Writer_Exception

Definition at line 559 of file Style.php.

References $objWriter.

Referenced by _writeCellStyleDxf(), and writeStyles().

560  {
561  // Translate formatcode
562  $formatCode = $pNumberFormat->getFormatCode();
563 
564  // numFmt
565  if ($formatCode !== NULL) {
566  $objWriter->startElement('numFmt');
567  $objWriter->writeAttribute('numFmtId', ($pId + 164));
568  $objWriter->writeAttribute('formatCode', $formatCode);
569  $objWriter->endElement();
570  }
571  }
getFormatCode()
Get Format Code.
+ Here is the caller graph for this function:

◆ _writePatternFill()

PHPExcel_Writer_Excel2007_Style::_writePatternFill ( PHPExcel_Shared_XMLWriter  $objWriter = null,
PHPExcel_Style_Fill  $pFill = null 
)
private

Write Pattern Fill.

Parameters
PHPExcel_Shared_XMLWriter$objWriterXML Writer
PHPExcel_Style_Fill$pFillFill style
Exceptions
PHPExcel_Writer_Exception

Definition at line 239 of file Style.php.

References $objWriter, and PHPExcel_Style_Fill\FILL_NONE.

Referenced by _writeFill().

240  {
241  // fill
242  $objWriter->startElement('fill');
243 
244  // patternFill
245  $objWriter->startElement('patternFill');
246  $objWriter->writeAttribute('patternType', $pFill->getFillType());
247 
248  if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
249  // fgColor
250  if ($pFill->getStartColor()->getARGB()) {
251  $objWriter->startElement('fgColor');
252  $objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
253  $objWriter->endElement();
254  }
255  }
256  if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
257  // bgColor
258  if ($pFill->getEndColor()->getARGB()) {
259  $objWriter->startElement('bgColor');
260  $objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
261  $objWriter->endElement();
262  }
263  }
264 
265  $objWriter->endElement();
266 
267  $objWriter->endElement();
268  }
const FILL_NONE
Definition: Fill.php:39
getStartColor()
Get Start Color.
Definition: Fill.php:250
getEndColor()
Get End Color.
Definition: Fill.php:279
getFillType()
Get Fill Type.
Definition: Fill.php:194
+ Here is the caller graph for this function:

◆ allBorders()

PHPExcel_Writer_Excel2007_Style::allBorders ( PHPExcel  $pPHPExcel = null)

Get an array of all borders.

Parameters
PHPExcel$pPHPExcel
Returns
PHPExcel_Style_Borders[] All borders in PHPExcel
Exceptions
PHPExcel_Writer_Exception

Definition at line 671 of file Style.php.

References $style, allStyles(), and array.

672  {
673  // Get an array of unique borders
674  $aBorders = array();
675  $aStyles = $this->allStyles($pPHPExcel);
676 
677  foreach ($aStyles as $style) {
678  if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) {
679  $aBorders[ $style->getBorders()->getHashCode() ] = $style->getBorders();
680  }
681  }
682 
683  return $aBorders;
684  }
$style
Definition: example_012.php:70
Create styles array
The data for the language used.
allStyles(PHPExcel $pPHPExcel=null)
Get an array of all styles.
Definition: Style.php:580
+ Here is the call graph for this function:

◆ allConditionalStyles()

PHPExcel_Writer_Excel2007_Style::allConditionalStyles ( PHPExcel  $pPHPExcel = null)

Get an array of all conditional styles.

Parameters
PHPExcel$pPHPExcel
Returns
PHPExcel_Style_Conditional[] All conditional styles in PHPExcel
Exceptions
PHPExcel_Writer_Exception

Definition at line 594 of file Style.php.

References $conditionalStyles, $i, and array.

595  {
596  // Get an array of all styles
597  $aStyles = array();
598 
599  $sheetCount = $pPHPExcel->getSheetCount();
600  for ($i = 0; $i < $sheetCount; ++$i) {
601  foreach ($pPHPExcel->getSheet($i)->getConditionalStylesCollection() as $conditionalStyles) {
602  foreach ($conditionalStyles as $conditionalStyle) {
603  $aStyles[] = $conditionalStyle;
604  }
605  }
606  }
607 
608  return $aStyles;
609  }
getSheetCount()
Get sheet count.
Definition: PHPExcel.php:661
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
getSheet($pIndex=0)
Get sheet by index.
Definition: PHPExcel.php:573

◆ allFills()

PHPExcel_Writer_Excel2007_Style::allFills ( PHPExcel  $pPHPExcel = null)

Get an array of all fills.

Parameters
PHPExcel$pPHPExcel
Returns
PHPExcel_Style_Fill[] All fills in PHPExcel
Exceptions
PHPExcel_Writer_Exception

Definition at line 618 of file Style.php.

References $style, allStyles(), array, PHPExcel_Style_Fill\FILL_NONE, and PHPExcel_Style_Fill\FILL_PATTERN_GRAY125.

619  {
620  // Get an array of unique fills
621  $aFills = array();
622 
623  // Two first fills are predefined
624  $fill0 = new PHPExcel_Style_Fill();
625  $fill0->setFillType(PHPExcel_Style_Fill::FILL_NONE);
626  $aFills[] = $fill0;
627 
628  $fill1 = new PHPExcel_Style_Fill();
629  $fill1->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_GRAY125);
630  $aFills[] = $fill1;
631  // The remaining fills
632  $aStyles = $this->allStyles($pPHPExcel);
633  foreach ($aStyles as $style) {
634  if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) {
635  $aFills[ $style->getFill()->getHashCode() ] = $style->getFill();
636  }
637  }
638 
639  return $aFills;
640  }
const FILL_NONE
Definition: Fill.php:39
$style
Definition: example_012.php:70
const FILL_PATTERN_GRAY125
Definition: Fill.php:51
Create styles array
The data for the language used.
allStyles(PHPExcel $pPHPExcel=null)
Get an array of all styles.
Definition: Style.php:580
+ Here is the call graph for this function:

◆ allFonts()

PHPExcel_Writer_Excel2007_Style::allFonts ( PHPExcel  $pPHPExcel = null)

Get an array of all fonts.

Parameters
PHPExcel$pPHPExcel
Returns
PHPExcel_Style_Font[] All fonts in PHPExcel
Exceptions
PHPExcel_Writer_Exception

Definition at line 649 of file Style.php.

References $style, allStyles(), and array.

650  {
651  // Get an array of unique fonts
652  $aFonts = array();
653  $aStyles = $this->allStyles($pPHPExcel);
654 
655  foreach ($aStyles as $style) {
656  if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) {
657  $aFonts[ $style->getFont()->getHashCode() ] = $style->getFont();
658  }
659  }
660 
661  return $aFonts;
662  }
$style
Definition: example_012.php:70
Create styles array
The data for the language used.
allStyles(PHPExcel $pPHPExcel=null)
Get an array of all styles.
Definition: Style.php:580
+ Here is the call graph for this function:

◆ allNumberFormats()

PHPExcel_Writer_Excel2007_Style::allNumberFormats ( PHPExcel  $pPHPExcel = null)

Get an array of all number formats.

Parameters
PHPExcel$pPHPExcel
Returns
PHPExcel_Style_NumberFormat[] All number formats in PHPExcel
Exceptions
PHPExcel_Writer_Exception

Definition at line 693 of file Style.php.

References $style, allStyles(), and array.

694  {
695  // Get an array of unique number formats
696  $aNumFmts = array();
697  $aStyles = $this->allStyles($pPHPExcel);
698 
699  foreach ($aStyles as $style) {
700  if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) {
701  $aNumFmts[ $style->getNumberFormat()->getHashCode() ] = $style->getNumberFormat();
702  }
703  }
704 
705  return $aNumFmts;
706  }
$style
Definition: example_012.php:70
Create styles array
The data for the language used.
allStyles(PHPExcel $pPHPExcel=null)
Get an array of all styles.
Definition: Style.php:580
+ Here is the call graph for this function:

◆ allStyles()

PHPExcel_Writer_Excel2007_Style::allStyles ( PHPExcel  $pPHPExcel = null)

Get an array of all styles.

Parameters
PHPExcel$pPHPExcel
Returns
PHPExcel_Style[] All styles in PHPExcel
Exceptions
PHPExcel_Writer_Exception

Definition at line 580 of file Style.php.

Referenced by allBorders(), allFills(), allFonts(), and allNumberFormats().

581  {
582  $aStyles = $pPHPExcel->getCellXfCollection();
583 
584  return $aStyles;
585  }
getCellXfCollection()
Get the workbook collection of cellXfs.
Definition: PHPExcel.php:876
+ Here is the caller graph for this function:

◆ writeStyles()

PHPExcel_Writer_Excel2007_Style::writeStyles ( PHPExcel  $pPHPExcel = null)

Write styles to XML format.

Parameters
PHPExcel$pPHPExcel
Returns
string XML Output
Exceptions
PHPExcel_Writer_Exception

Definition at line 45 of file Style.php.

References $i, $objWriter, _writeBorder(), _writeCellStyleDxf(), _writeCellStyleXf(), _writeFill(), _writeFont(), _writeNumFmt(), PHPExcel_Writer_Excel2007_WriterPart\getParentWriter(), PHPExcel_Shared_XMLWriter\STORAGE_DISK, and PHPExcel_Shared_XMLWriter\STORAGE_MEMORY.

46  {
47  // Create XML writer
48  $objWriter = null;
49  if ($this->getParentWriter()->getUseDiskCaching()) {
51  } else {
53  }
54 
55  // XML header
56  $objWriter->startDocument('1.0','UTF-8','yes');
57 
58  // styleSheet
59  $objWriter->startElement('styleSheet');
60  $objWriter->writeAttribute('xml:space', 'preserve');
61  $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
62 
63  // numFmts
64  $objWriter->startElement('numFmts');
65  $objWriter->writeAttribute('count', $this->getParentWriter()->getNumFmtHashTable()->count());
66 
67  // numFmt
68  for ($i = 0; $i < $this->getParentWriter()->getNumFmtHashTable()->count(); ++$i) {
69  $this->_writeNumFmt($objWriter, $this->getParentWriter()->getNumFmtHashTable()->getByIndex($i), $i);
70  }
71 
72  $objWriter->endElement();
73 
74  // fonts
75  $objWriter->startElement('fonts');
76  $objWriter->writeAttribute('count', $this->getParentWriter()->getFontHashTable()->count());
77 
78  // font
79  for ($i = 0; $i < $this->getParentWriter()->getFontHashTable()->count(); ++$i) {
80  $this->_writeFont($objWriter, $this->getParentWriter()->getFontHashTable()->getByIndex($i));
81  }
82 
83  $objWriter->endElement();
84 
85  // fills
86  $objWriter->startElement('fills');
87  $objWriter->writeAttribute('count', $this->getParentWriter()->getFillHashTable()->count());
88 
89  // fill
90  for ($i = 0; $i < $this->getParentWriter()->getFillHashTable()->count(); ++$i) {
91  $this->_writeFill($objWriter, $this->getParentWriter()->getFillHashTable()->getByIndex($i));
92  }
93 
94  $objWriter->endElement();
95 
96  // borders
97  $objWriter->startElement('borders');
98  $objWriter->writeAttribute('count', $this->getParentWriter()->getBordersHashTable()->count());
99 
100  // border
101  for ($i = 0; $i < $this->getParentWriter()->getBordersHashTable()->count(); ++$i) {
102  $this->_writeBorder($objWriter, $this->getParentWriter()->getBordersHashTable()->getByIndex($i));
103  }
104 
105  $objWriter->endElement();
106 
107  // cellStyleXfs
108  $objWriter->startElement('cellStyleXfs');
109  $objWriter->writeAttribute('count', 1);
110 
111  // xf
112  $objWriter->startElement('xf');
113  $objWriter->writeAttribute('numFmtId', 0);
114  $objWriter->writeAttribute('fontId', 0);
115  $objWriter->writeAttribute('fillId', 0);
116  $objWriter->writeAttribute('borderId', 0);
117  $objWriter->endElement();
118 
119  $objWriter->endElement();
120 
121  // cellXfs
122  $objWriter->startElement('cellXfs');
123  $objWriter->writeAttribute('count', count($pPHPExcel->getCellXfCollection()));
124 
125  // xf
126  foreach ($pPHPExcel->getCellXfCollection() as $cellXf) {
127  $this->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel);
128  }
129 
130  $objWriter->endElement();
131 
132  // cellStyles
133  $objWriter->startElement('cellStyles');
134  $objWriter->writeAttribute('count', 1);
135 
136  // cellStyle
137  $objWriter->startElement('cellStyle');
138  $objWriter->writeAttribute('name', 'Normal');
139  $objWriter->writeAttribute('xfId', 0);
140  $objWriter->writeAttribute('builtinId', 0);
141  $objWriter->endElement();
142 
143  $objWriter->endElement();
144 
145  // dxfs
146  $objWriter->startElement('dxfs');
147  $objWriter->writeAttribute('count', $this->getParentWriter()->getStylesConditionalHashTable()->count());
148 
149  // dxf
150  for ($i = 0; $i < $this->getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) {
151  $this->_writeCellStyleDxf($objWriter, $this->getParentWriter()->getStylesConditionalHashTable()->getByIndex($i)->getStyle());
152  }
153 
154  $objWriter->endElement();
155 
156  // tableStyles
157  $objWriter->startElement('tableStyles');
158  $objWriter->writeAttribute('defaultTableStyle', 'TableStyleMedium9');
159  $objWriter->writeAttribute('defaultPivotStyle', 'PivotTableStyle1');
160  $objWriter->endElement();
161 
162  $objWriter->endElement();
163 
164  // Return
165  return $objWriter->getData();
166  }
getCellXfCollection()
Get the workbook collection of cellXfs.
Definition: PHPExcel.php:876
_writeCellStyleXf(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style $pStyle=null, PHPExcel $pPHPExcel=null)
Write Cell Style Xf.
Definition: Style.php:394
getParentWriter()
Get parent IWriter object.
Definition: WriterPart.php:61
$objWriter
_writeFill(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Fill $pFill=null)
Write Fill.
Definition: Style.php:175
_writeFont(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Font $pFont=null)
Write Font.
Definition: Style.php:277
$i
Definition: disco.tpl.php:19
_writeNumFmt(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_NumberFormat $pNumberFormat=null, $pId=0)
Write NumberFormat.
Definition: Style.php:559
const STORAGE_MEMORY
Temporary storage method.
Definition: XMLWriter.php:46
_writeBorder(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style_Borders $pBorders=null)
Write Border.
Definition: Style.php:357
_writeCellStyleDxf(PHPExcel_Shared_XMLWriter $objWriter=null, PHPExcel_Style $pStyle=null)
Write Cell Style Dxf.
Definition: Style.php:469
+ Here is the call graph for this function:

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