You are here

private function PHPExcel_Writer_Excel2007_Style::_writeCellStyleXf in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php \PHPExcel_Writer_Excel2007_Style::_writeCellStyleXf()

* Write Cell Style Xf * *

Parameters

PHPExcel_Shared_XMLWriter $objWriter XML Writer: * @param PHPExcel_Style $pStyle Style * @param PHPExcel $pPHPExcel Workbook * @throws PHPExcel_Writer_Exception

1 call to PHPExcel_Writer_Excel2007_Style::_writeCellStyleXf()
PHPExcel_Writer_Excel2007_Style::writeStyles in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php
* Write styles to XML format * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Style.php, line 394

Class

PHPExcel_Writer_Excel2007_Style
PHPExcel_Writer_Excel2007_Style

Code

private function _writeCellStyleXf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null, PHPExcel $pPHPExcel = null) {

  // xf
  $objWriter
    ->startElement('xf');
  $objWriter
    ->writeAttribute('xfId', 0);
  $objWriter
    ->writeAttribute('fontId', (int) $this
    ->getParentWriter()
    ->getFontHashTable()
    ->getIndexForHashCode($pStyle
    ->getFont()
    ->getHashCode()));
  if ($pStyle
    ->getQuotePrefix()) {
    $objWriter
      ->writeAttribute('quotePrefix', 1);
  }
  if ($pStyle
    ->getNumberFormat()
    ->getBuiltInFormatCode() === false) {
    $objWriter
      ->writeAttribute('numFmtId', (int) ($this
      ->getParentWriter()
      ->getNumFmtHashTable()
      ->getIndexForHashCode($pStyle
      ->getNumberFormat()
      ->getHashCode()) + 164));
  }
  else {
    $objWriter
      ->writeAttribute('numFmtId', (int) $pStyle
      ->getNumberFormat()
      ->getBuiltInFormatCode());
  }
  $objWriter
    ->writeAttribute('fillId', (int) $this
    ->getParentWriter()
    ->getFillHashTable()
    ->getIndexForHashCode($pStyle
    ->getFill()
    ->getHashCode()));
  $objWriter
    ->writeAttribute('borderId', (int) $this
    ->getParentWriter()
    ->getBordersHashTable()
    ->getIndexForHashCode($pStyle
    ->getBorders()
    ->getHashCode()));

  // Apply styles?
  $objWriter
    ->writeAttribute('applyFont', $pPHPExcel
    ->getDefaultStyle()
    ->getFont()
    ->getHashCode() != $pStyle
    ->getFont()
    ->getHashCode() ? '1' : '0');
  $objWriter
    ->writeAttribute('applyNumberFormat', $pPHPExcel
    ->getDefaultStyle()
    ->getNumberFormat()
    ->getHashCode() != $pStyle
    ->getNumberFormat()
    ->getHashCode() ? '1' : '0');
  $objWriter
    ->writeAttribute('applyFill', $pPHPExcel
    ->getDefaultStyle()
    ->getFill()
    ->getHashCode() != $pStyle
    ->getFill()
    ->getHashCode() ? '1' : '0');
  $objWriter
    ->writeAttribute('applyBorder', $pPHPExcel
    ->getDefaultStyle()
    ->getBorders()
    ->getHashCode() != $pStyle
    ->getBorders()
    ->getHashCode() ? '1' : '0');
  $objWriter
    ->writeAttribute('applyAlignment', $pPHPExcel
    ->getDefaultStyle()
    ->getAlignment()
    ->getHashCode() != $pStyle
    ->getAlignment()
    ->getHashCode() ? '1' : '0');
  if ($pStyle
    ->getProtection()
    ->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle
    ->getProtection()
    ->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
    $objWriter
      ->writeAttribute('applyProtection', 'true');
  }

  // alignment
  $objWriter
    ->startElement('alignment');
  $objWriter
    ->writeAttribute('horizontal', $pStyle
    ->getAlignment()
    ->getHorizontal());
  $objWriter
    ->writeAttribute('vertical', $pStyle
    ->getAlignment()
    ->getVertical());
  $textRotation = 0;
  if ($pStyle
    ->getAlignment()
    ->getTextRotation() >= 0) {
    $textRotation = $pStyle
      ->getAlignment()
      ->getTextRotation();
  }
  else {
    if ($pStyle
      ->getAlignment()
      ->getTextRotation() < 0) {
      $textRotation = 90 - $pStyle
        ->getAlignment()
        ->getTextRotation();
    }
  }
  $objWriter
    ->writeAttribute('textRotation', $textRotation);
  $objWriter
    ->writeAttribute('wrapText', $pStyle
    ->getAlignment()
    ->getWrapText() ? 'true' : 'false');
  $objWriter
    ->writeAttribute('shrinkToFit', $pStyle
    ->getAlignment()
    ->getShrinkToFit() ? 'true' : 'false');
  if ($pStyle
    ->getAlignment()
    ->getIndent() > 0) {
    $objWriter
      ->writeAttribute('indent', $pStyle
      ->getAlignment()
      ->getIndent());
  }
  if ($pStyle
    ->getAlignment()
    ->getReadorder() > 0) {
    $objWriter
      ->writeAttribute('readingOrder', $pStyle
      ->getAlignment()
      ->getReadorder());
  }
  $objWriter
    ->endElement();

  // protection
  if ($pStyle
    ->getProtection()
    ->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle
    ->getProtection()
    ->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
    $objWriter
      ->startElement('protection');
    if ($pStyle
      ->getProtection()
      ->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
      $objWriter
        ->writeAttribute('locked', $pStyle
        ->getProtection()
        ->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false');
    }
    if ($pStyle
      ->getProtection()
      ->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
      $objWriter
        ->writeAttribute('hidden', $pStyle
        ->getProtection()
        ->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false');
    }
    $objWriter
      ->endElement();
  }
  $objWriter
    ->endElement();
}