You are here

public function PHPExcel_Writer_Excel2007_Workbook::writeWorkbook in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Workbook.php \PHPExcel_Writer_Excel2007_Workbook::writeWorkbook()

* Write workbook to XML format * *

Parameters

PHPExcel $pPHPExcel: * @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing * @return string XML Output * @throws PHPExcel_Writer_Exception

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Workbook.php, line 46

Class

PHPExcel_Writer_Excel2007_Workbook
PHPExcel_Writer_Excel2007_Workbook

Code

public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = FALSE) {

  // Create XML writer
  $objWriter = null;
  if ($this
    ->getParentWriter()
    ->getUseDiskCaching()) {
    $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this
      ->getParentWriter()
      ->getDiskCachingDirectory());
  }
  else {
    $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  }

  // XML header
  $objWriter
    ->startDocument('1.0', 'UTF-8', 'yes');

  // workbook
  $objWriter
    ->startElement('workbook');
  $objWriter
    ->writeAttribute('xml:space', 'preserve');
  $objWriter
    ->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
  $objWriter
    ->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');

  // fileVersion
  $this
    ->_writeFileVersion($objWriter);

  // workbookPr
  $this
    ->_writeWorkbookPr($objWriter);

  // workbookProtection
  $this
    ->_writeWorkbookProtection($objWriter, $pPHPExcel);

  // bookViews
  if ($this
    ->getParentWriter()
    ->getOffice2003Compatibility() === false) {
    $this
      ->_writeBookViews($objWriter, $pPHPExcel);
  }

  // sheets
  $this
    ->_writeSheets($objWriter, $pPHPExcel);

  // definedNames
  $this
    ->_writeDefinedNames($objWriter, $pPHPExcel);

  // calcPr
  $this
    ->_writeCalcPr($objWriter, $recalcRequired);
  $objWriter
    ->endElement();

  // Return
  return $objWriter
    ->getData();
}