You are here

public function PHPExcel_Writer_Excel2007_Drawing::writeDrawings in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Drawing.php \PHPExcel_Writer_Excel2007_Drawing::writeDrawings()

* Write drawings to XML format * *

Parameters

PHPExcel_Worksheet $pWorksheet: * @param int &$chartRef Chart ID * @param boolean $includeCharts Flag indicating if we should include drawing details for charts * @return string XML Output * @throws PHPExcel_Writer_Exception

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007/Drawing.php, line 47

Class

PHPExcel_Writer_Excel2007_Drawing
PHPExcel_Writer_Excel2007_Drawing

Code

public function writeDrawings(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = 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');

  // xdr:wsDr
  $objWriter
    ->startElement('xdr:wsDr');
  $objWriter
    ->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
  $objWriter
    ->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');

  // Loop through images and write drawings
  $i = 1;
  $iterator = $pWorksheet
    ->getDrawingCollection()
    ->getIterator();
  while ($iterator
    ->valid()) {
    $this
      ->_writeDrawing($objWriter, $iterator
      ->current(), $i);
    $iterator
      ->next();
    ++$i;
  }
  if ($includeCharts) {
    $chartCount = $pWorksheet
      ->getChartCount();

    // Loop through charts and write the chart position
    if ($chartCount > 0) {
      for ($c = 0; $c < $chartCount; ++$c) {
        $this
          ->_writeChart($objWriter, $pWorksheet
          ->getChartByIndex($c), $c + $i);
      }
    }
  }
  $objWriter
    ->endElement();

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