Write docProps/custom.xml to XML format

@param 	PHPExcel	$pPHPExcel
@return 	string 		XML Output
@throws 	PHPExcel_Writer_Exception
7136
public function writeDocPropsCustom(PHPExcel $pPHPExcel = null)
	{
		$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
		if (empty($customPropertyList)) {
			return;
		}

		// 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');

		// cp:coreProperties
		$objWriter->startElement('Properties');
			$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
			$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');


			foreach($customPropertyList as $key => $customProperty) {
				$propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
				$propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);

				$objWriter->startElement('property');
					$objWriter->writeAttribute('fmtid', 	'{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
					$objWriter->writeAttribute('pid', 		$key+2);
					$objWriter->writeAttribute('name', 		$customProperty);

					switch($propertyType) {
						case 'i' :
							$objWriter->writeElement('vt:i4', 		$propertyValue);
							break;
						case 'f' :
							$objWriter->writeElement('vt:r8', 		$propertyValue);
							break;
						case 'b' :
							$objWriter->writeElement('vt:bool', 	($propertyValue) ? 'true' : 'false');
							break;
						case 'd' :
							$objWriter->startElement('vt:filetime');
								$objWriter->writeRawData(date(DATE_W3C, $propertyValue));
							$objWriter->endElement();
							break;
						default :
							$objWriter->writeElement('vt:lpwstr', 	$propertyValue);
							break;
					}

				$objWriter->endElement();
			}


		$objWriter->endElement();

		// Return
		return $objWriter->getData();
	}
1350727
private function _writeProtectedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
	{
		if (count($pSheet->getProtectedCells()) > 0) {
			// protectedRanges
			$objWriter->startElement('protectedRanges');

				// Loop protectedRanges
				foreach ($pSheet->getProtectedCells() as $protectedCell => $passwordHash) {
					// protectedRange
					$objWriter->startElement('protectedRange');
					$objWriter->writeAttribute('name',		'p' . md5($protectedCell));
					$objWriter->writeAttribute('sqref',	$protectedCell);
					if (!empty($passwordHash)) {
						$objWriter->writeAttribute('password',	$passwordHash);
					}
					$objWriter->endElement();
				}

			$objWriter->endElement();
		}
	}
738490
private function _writeConditionalFormatting(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
	{
		// Conditional id
		$id = 1;

		// Loop through styles in the current worksheet
		foreach ($pSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) {
			foreach ($conditionalStyles as $conditional) {
				// WHY was this again?
				// if ($this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode( $conditional->getHashCode() ) == '') {
				//	continue;
				// }
				if ($conditional->getConditionType() != PHPExcel_Style_Conditional::CONDITION_NONE) {
					// conditionalFormatting
					$objWriter->startElement('conditionalFormatting');
					$objWriter->writeAttribute('sqref',	$cellCoordinate);

						// cfRule
						$objWriter->startElement('cfRule');
						$objWriter->writeAttribute('type',		$conditional->getConditionType());
						$objWriter->writeAttribute('dxfId',		$this->getParentWriter()->getStylesConditionalHashTable()->getIndexForHashCode( $conditional->getHashCode() ));
						$objWriter->writeAttribute('priority',	$id++);

						if (($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
								||
							 $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT)
							&& $conditional->getOperatorType() != PHPExcel_Style_Conditional::OPERATOR_NONE) {
							$objWriter->writeAttribute('operator',	$conditional->getOperatorType());
						}

						if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
							&& !is_null($conditional->getText())) {
							$objWriter->writeAttribute('text',	$conditional->getText());
						}

						if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
							&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT
							&& !is_null($conditional->getText())) {
							$objWriter->writeElement('formula',	'NOT(ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . ')))');
						} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
							&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_BEGINSWITH
							&& !is_null($conditional->getText())) {
							$objWriter->writeElement('formula',	'LEFT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
						} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
							&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_ENDSWITH
							&& !is_null($conditional->getText())) {
							$objWriter->writeElement('formula',	'RIGHT(' . $cellCoordinate . ',' . strlen($conditional->getText()) . ')="' . $conditional->getText() . '"');
						} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
							&& $conditional->getOperatorType() == PHPExcel_Style_Conditional::OPERATOR_NOTCONTAINS
							&& !is_null($conditional->getText())) {
							$objWriter->writeElement('formula',	'ISERROR(SEARCH("' . $conditional->getText() . '",' . $cellCoordinate . '))');
						} else if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CELLIS
							|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
							|| $conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) {
							foreach ($conditional->getConditions() as $formula) {
								// Formula
								$objWriter->writeElement('formula',	$formula);
							}
						}

						$objWriter->endElement();

					$objWriter->endElement();
				}
			}
		}
	}
1174162
public function save($pFilename = null) {

		// garbage collect
		$this->_phpExcel->garbageCollect();

		$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
		PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
		$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
		PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);

		// initialize colors array
		$this->_colors          = array();

		// Initialise workbook writer
		$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel,
																	 $this->_str_total, $this->_str_unique, $this->_str_table,
																	 $this->_colors, $this->_parser);

		// Initialise worksheet writers
		$countSheets = $this->_phpExcel->getSheetCount();
		for ($i = 0; $i < $countSheets; ++$i) {
			$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique,
																			   $this->_str_table, $this->_colors,
																			   $this->_parser,
																			   $this->_preCalculateFormulas,
																			   $this->_phpExcel->getSheet($i));
		}

		// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.
		$this->_buildWorksheetEschers();
		$this->_buildWorkbookEscher();

		// add 15 identical cell style Xfs
		// for now, we use the first cellXf instead of cellStyleXf
		$cellXfCollection = $this->_phpExcel->getCellXfCollection();
		for ($i = 0; $i < 15; ++$i) {
			$this->_writerWorkbook->addXfWriter($cellXfCollection[0], true);
		}

		// add all the cell Xfs
		foreach ($this->_phpExcel->getCellXfCollection() as $style) {
			$this->_writerWorkbook->addXfWriter($style, false);
		}

		// add fonts from rich text eleemnts
		for ($i = 0; $i < $countSheets; ++$i) {
			foreach ($this->_writerWorksheets[$i]->_phpSheet->getCellCollection() as $cellID) {
				$cell = $this->_writerWorksheets[$i]->_phpSheet->getCell($cellID);
				$cVal = $cell->getValue();
				if ($cVal instanceof PHPExcel_RichText) {
					$elements = $cVal->getRichTextElements();
					foreach ($elements as $element) {
						if ($element instanceof PHPExcel_RichText_Run) {
							$font = $element->getFont();
							$this->_writerWorksheets[$i]->_fntHashIndex[$font->getHashCode()] = $this->_writerWorkbook->_addFont($font);
						}
					}
				}
			}
		}

		// initialize OLE file
		$workbookStreamName = 'Workbook';
		$OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));

		// Write the worksheet streams before the global workbook stream,
		// because the byte sizes of these are needed in the global workbook stream
		$worksheetSizes = array();
		for ($i = 0; $i < $countSheets; ++$i) {
			$this->_writerWorksheets[$i]->close();
			$worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
		}

		// add binary data for global workbook stream
		$OLE->append($this->_writerWorkbook->writeWorkbook($worksheetSizes));

		// add binary data for sheet streams
		for ($i = 0; $i < $countSheets; ++$i) {
			$OLE->append($this->_writerWorksheets[$i]->getData());
		}

		$this->_documentSummaryInformation = $this->_writeDocumentSummaryInformation();
		// initialize OLE Document Summary Information
		if(isset($this->_documentSummaryInformation) && !empty($this->_documentSummaryInformation)){
			$OLE_DocumentSummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation'));
			$OLE_DocumentSummaryInformation->append($this->_documentSummaryInformation);
		}

		$this->_summaryInformation = $this->_writeSummaryInformation();
		// initialize OLE Summary Information
		if(isset($this->_summaryInformation) && !empty($this->_summaryInformation)){
		  $OLE_SummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'SummaryInformation'));
		  $OLE_SummaryInformation->append($this->_summaryInformation);
		}

		// define OLE Parts
		$arrRootData = array($OLE);
		// initialize OLE Properties file
		if(isset($OLE_SummaryInformation)){
			$arrRootData[] = $OLE_SummaryInformation;
		}
		// initialize OLE Extended Properties file
		if(isset($OLE_DocumentSummaryInformation)){
			$arrRootData[] = $OLE_DocumentSummaryInformation;
		}

		$root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), $arrRootData);
		// save the OLE file
		$res = $root->save($pFilename);

		PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
		PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
	}
272384
private function writeDefinedNameForPrintTitles(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
    {
        // definedName for PrintTitles
        if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
            $objWriter->startElement('definedName');
            $objWriter->writeAttribute('name', '_xlnm.Print_Titles');
            $objWriter->writeAttribute('localSheetId', $pSheetId);

            // Setting string
            $settingString = '';

            // Columns to repeat
            if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
                $repeat = $pSheet->getPageSetup()->getColumnsToRepeatAtLeft();

                $settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
            }

            // Rows to repeat
            if ($pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
                if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
                    $settingString .= ',';
                }

                $repeat = $pSheet->getPageSetup()->getRowsToRepeatAtTop();

                $settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
            }

            $objWriter->writeRawData($settingString);

            $objWriter->endElement();
        }
    }
1122538
public function writeTheme(PHPExcel $pPHPExcel = null)
    {
        // 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');

        // a:theme
        $objWriter->startElement('a:theme');
        $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
        $objWriter->writeAttribute('name', 'Office Theme');

            // a:themeElements
            $objWriter->startElement('a:themeElements');

                // a:clrScheme
                $objWriter->startElement('a:clrScheme');
                $objWriter->writeAttribute('name', 'Office');

                    // a:dk1
                    $objWriter->startElement('a:dk1');

                        // a:sysClr
                        $objWriter->startElement('a:sysClr');
                        $objWriter->writeAttribute('val', 'windowText');
                        $objWriter->writeAttribute('lastClr', '000000');
                        $objWriter->endElement();

                    $objWriter->endElement();

                    // a:lt1
                    $objWriter->startElement('a:lt1');

                        // a:sysClr
                        $objWriter->startElement('a:sysClr');
                        $objWriter->writeAttribute('val', 'window');
                        $objWriter->writeAttribute('lastClr', 'FFFFFF');
                        $objWriter->endElement();

                    $objWriter->endElement();

                    // a:dk2
                    $this->writeColourScheme($objWriter);

                $objWriter->endElement();

                // a:fontScheme
                $objWriter->startElement('a:fontScheme');
                $objWriter->writeAttribute('name', 'Office');

                    // a:majorFont
                    $objWriter->startElement('a:majorFont');
                        $this->writeFonts($objWriter, 'Cambria', self::$majorFonts);
                    $objWriter->endElement();

                    // a:minorFont
                    $objWriter->startElement('a:minorFont');
                        $this->writeFonts($objWriter, 'Calibri', self::$minorFonts);
                    $objWriter->endElement();

                $objWriter->endElement();

                // a:fmtScheme
                $objWriter->startElement('a:fmtScheme');
                $objWriter->writeAttribute('name', 'Office');

                    // a:fillStyleLst
                    $objWriter->startElement('a:fillStyleLst');

                        // a:solidFill
                        $objWriter->startElement('a:solidFill');

                            // a:schemeClr
                            $objWriter->startElement('a:schemeClr');
                            $objWriter->writeAttribute('val', 'phClr');
                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:gradFill
                        $objWriter->startElement('a:gradFill');
                        $objWriter->writeAttribute('rotWithShape', '1');

                            // a:gsLst
                            $objWriter->startElement('a:gsLst');

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '0');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:tint
                                        $objWriter->startElement('a:tint');
                                        $objWriter->writeAttribute('val', '50000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '300000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '35000');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:tint
                                        $objWriter->startElement('a:tint');
                                        $objWriter->writeAttribute('val', '37000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '300000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '100000');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:tint
                                        $objWriter->startElement('a:tint');
                                        $objWriter->writeAttribute('val', '15000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '350000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:lin
                            $objWriter->startElement('a:lin');
                            $objWriter->writeAttribute('ang', '16200000');
                            $objWriter->writeAttribute('scaled', '1');
                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:gradFill
                        $objWriter->startElement('a:gradFill');
                        $objWriter->writeAttribute('rotWithShape', '1');

                            // a:gsLst
                            $objWriter->startElement('a:gsLst');

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '0');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:shade
                                        $objWriter->startElement('a:shade');
                                        $objWriter->writeAttribute('val', '51000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '130000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '80000');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:shade
                                        $objWriter->startElement('a:shade');
                                        $objWriter->writeAttribute('val', '93000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '130000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '100000');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:shade
                                        $objWriter->startElement('a:shade');
                                        $objWriter->writeAttribute('val', '94000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '135000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:lin
                            $objWriter->startElement('a:lin');
                            $objWriter->writeAttribute('ang', '16200000');
                            $objWriter->writeAttribute('scaled', '0');
                            $objWriter->endElement();

                        $objWriter->endElement();

                    $objWriter->endElement();

                    // a:lnStyleLst
                    $objWriter->startElement('a:lnStyleLst');

                        // a:ln
                        $objWriter->startElement('a:ln');
                        $objWriter->writeAttribute('w', '9525');
                        $objWriter->writeAttribute('cap', 'flat');
                        $objWriter->writeAttribute('cmpd', 'sng');
                        $objWriter->writeAttribute('algn', 'ctr');

                            // a:solidFill
                            $objWriter->startElement('a:solidFill');

                                // a:schemeClr
                                $objWriter->startElement('a:schemeClr');
                                $objWriter->writeAttribute('val', 'phClr');

                                        // a:shade
                                        $objWriter->startElement('a:shade');
                                        $objWriter->writeAttribute('val', '95000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '105000');
                                        $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:prstDash
                            $objWriter->startElement('a:prstDash');
                            $objWriter->writeAttribute('val', 'solid');
                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:ln
                        $objWriter->startElement('a:ln');
                        $objWriter->writeAttribute('w', '25400');
                        $objWriter->writeAttribute('cap', 'flat');
                        $objWriter->writeAttribute('cmpd', 'sng');
                        $objWriter->writeAttribute('algn', 'ctr');

                            // a:solidFill
                            $objWriter->startElement('a:solidFill');

                                // a:schemeClr
                                $objWriter->startElement('a:schemeClr');
                                $objWriter->writeAttribute('val', 'phClr');
                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:prstDash
                            $objWriter->startElement('a:prstDash');
                            $objWriter->writeAttribute('val', 'solid');
                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:ln
                        $objWriter->startElement('a:ln');
                        $objWriter->writeAttribute('w', '38100');
                        $objWriter->writeAttribute('cap', 'flat');
                        $objWriter->writeAttribute('cmpd', 'sng');
                        $objWriter->writeAttribute('algn', 'ctr');

                            // a:solidFill
                            $objWriter->startElement('a:solidFill');

                                // a:schemeClr
                                $objWriter->startElement('a:schemeClr');
                                $objWriter->writeAttribute('val', 'phClr');
                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:prstDash
                            $objWriter->startElement('a:prstDash');
                            $objWriter->writeAttribute('val', 'solid');
                            $objWriter->endElement();

                        $objWriter->endElement();

                    $objWriter->endElement();



                    // a:effectStyleLst
                    $objWriter->startElement('a:effectStyleLst');

                        // a:effectStyle
                        $objWriter->startElement('a:effectStyle');

                            // a:effectLst
                            $objWriter->startElement('a:effectLst');

                                // a:outerShdw
                                $objWriter->startElement('a:outerShdw');
                                $objWriter->writeAttribute('blurRad', '40000');
                                $objWriter->writeAttribute('dist', '20000');
                                $objWriter->writeAttribute('dir', '5400000');
                                $objWriter->writeAttribute('rotWithShape', '0');

                                    // a:srgbClr
                                    $objWriter->startElement('a:srgbClr');
                                    $objWriter->writeAttribute('val', '000000');

                                        // a:alpha
                                        $objWriter->startElement('a:alpha');
                                        $objWriter->writeAttribute('val', '38000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:effectStyle
                        $objWriter->startElement('a:effectStyle');

                            // a:effectLst
                            $objWriter->startElement('a:effectLst');

                                // a:outerShdw
                                $objWriter->startElement('a:outerShdw');
                                $objWriter->writeAttribute('blurRad', '40000');
                                $objWriter->writeAttribute('dist', '23000');
                                $objWriter->writeAttribute('dir', '5400000');
                                $objWriter->writeAttribute('rotWithShape', '0');

                                    // a:srgbClr
                                    $objWriter->startElement('a:srgbClr');
                                    $objWriter->writeAttribute('val', '000000');

                                        // a:alpha
                                        $objWriter->startElement('a:alpha');
                                        $objWriter->writeAttribute('val', '35000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:effectStyle
                        $objWriter->startElement('a:effectStyle');

                            // a:effectLst
                            $objWriter->startElement('a:effectLst');

                                // a:outerShdw
                                $objWriter->startElement('a:outerShdw');
                                $objWriter->writeAttribute('blurRad', '40000');
                                $objWriter->writeAttribute('dist', '23000');
                                $objWriter->writeAttribute('dir', '5400000');
                                $objWriter->writeAttribute('rotWithShape', '0');

                                    // a:srgbClr
                                    $objWriter->startElement('a:srgbClr');
                                    $objWriter->writeAttribute('val', '000000');

                                        // a:alpha
                                        $objWriter->startElement('a:alpha');
                                        $objWriter->writeAttribute('val', '35000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:scene3d
                            $objWriter->startElement('a:scene3d');

                                // a:camera
                                $objWriter->startElement('a:camera');
                                $objWriter->writeAttribute('prst', 'orthographicFront');

                                    // a:rot
                                    $objWriter->startElement('a:rot');
                                    $objWriter->writeAttribute('lat', '0');
                                    $objWriter->writeAttribute('lon', '0');
                                    $objWriter->writeAttribute('rev', '0');
                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:lightRig
                                $objWriter->startElement('a:lightRig');
                                $objWriter->writeAttribute('rig', 'threePt');
                                $objWriter->writeAttribute('dir', 't');

                                    // a:rot
                                    $objWriter->startElement('a:rot');
                                    $objWriter->writeAttribute('lat', '0');
                                    $objWriter->writeAttribute('lon', '0');
                                    $objWriter->writeAttribute('rev', '1200000');
                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:sp3d
                            $objWriter->startElement('a:sp3d');

                                // a:bevelT
                                $objWriter->startElement('a:bevelT');
                                $objWriter->writeAttribute('w', '63500');
                                $objWriter->writeAttribute('h', '25400');
                                $objWriter->endElement();

                            $objWriter->endElement();

                        $objWriter->endElement();

                    $objWriter->endElement();

                    // a:bgFillStyleLst
                    $objWriter->startElement('a:bgFillStyleLst');

                        // a:solidFill
                        $objWriter->startElement('a:solidFill');

                            // a:schemeClr
                            $objWriter->startElement('a:schemeClr');
                            $objWriter->writeAttribute('val', 'phClr');
                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:gradFill
                        $objWriter->startElement('a:gradFill');
                        $objWriter->writeAttribute('rotWithShape', '1');

                            // a:gsLst
                            $objWriter->startElement('a:gsLst');

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '0');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:tint
                                        $objWriter->startElement('a:tint');
                                        $objWriter->writeAttribute('val', '40000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '350000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '40000');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:tint
                                        $objWriter->startElement('a:tint');
                                        $objWriter->writeAttribute('val', '45000');
                                        $objWriter->endElement();

                                        // a:shade
                                        $objWriter->startElement('a:shade');
                                        $objWriter->writeAttribute('val', '99000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '350000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '100000');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:shade
                                        $objWriter->startElement('a:shade');
                                        $objWriter->writeAttribute('val', '20000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '255000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:path
                            $objWriter->startElement('a:path');
                            $objWriter->writeAttribute('path', 'circle');

                                // a:fillToRect
                                $objWriter->startElement('a:fillToRect');
                                $objWriter->writeAttribute('l', '50000');
                                $objWriter->writeAttribute('t', '-80000');
                                $objWriter->writeAttribute('r', '50000');
                                $objWriter->writeAttribute('b', '180000');
                                $objWriter->endElement();

                            $objWriter->endElement();

                        $objWriter->endElement();

                        // a:gradFill
                        $objWriter->startElement('a:gradFill');
                        $objWriter->writeAttribute('rotWithShape', '1');

                            // a:gsLst
                            $objWriter->startElement('a:gsLst');

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '0');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:tint
                                        $objWriter->startElement('a:tint');
                                        $objWriter->writeAttribute('val', '80000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '300000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                                // a:gs
                                $objWriter->startElement('a:gs');
                                $objWriter->writeAttribute('pos', '100000');

                                    // a:schemeClr
                                    $objWriter->startElement('a:schemeClr');
                                    $objWriter->writeAttribute('val', 'phClr');

                                        // a:shade
                                        $objWriter->startElement('a:shade');
                                        $objWriter->writeAttribute('val', '30000');
                                        $objWriter->endElement();

                                        // a:satMod
                                        $objWriter->startElement('a:satMod');
                                        $objWriter->writeAttribute('val', '200000');
                                        $objWriter->endElement();

                                    $objWriter->endElement();

                                $objWriter->endElement();

                            $objWriter->endElement();

                            // a:path
                            $objWriter->startElement('a:path');
                            $objWriter->writeAttribute('path', 'circle');

                                // a:fillToRect
                                $objWriter->startElement('a:fillToRect');
                                $objWriter->writeAttribute('l', '50000');
                                $objWriter->writeAttribute('t', '50000');
                                $objWriter->writeAttribute('r', '50000');
                                $objWriter->writeAttribute('b', '50000');
                                $objWriter->endElement();

                            $objWriter->endElement();

                        $objWriter->endElement();

                    $objWriter->endElement();

                $objWriter->endElement();

            $objWriter->endElement();

            // a:objectDefaults
            $objWriter->writeElement('a:objectDefaults', null);

            // a:extraClrSchemeLst
            $objWriter->writeElement('a:extraClrSchemeLst', null);

        $objWriter->endElement();

        // Return
        return $objWriter->getData();
    }
797792
private function writeWorkbookPr(PHPExcel_Shared_XMLWriter $objWriter = null)
    {
        $objWriter->startElement('workbookPr');

        if (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) {
            $objWriter->writeAttribute('date1904', '1');
        }

        $objWriter->writeAttribute('codeName', 'ThisWorkbook');

        $objWriter->endElement();
    }
946779
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
		// Search type
		$searchType = 'IWriter';

		// Include class
		foreach (self::$_searchLocations as $searchLocation) {
			if ($searchLocation['type'] == $searchType) {
				$className = str_replace('{0}', $writerType, $searchLocation['class']);

				$instance = new $className($phpExcel);
				if ($instance !== NULL) {
					return $instance;
				}
			}
		}

		// Nothing found...
		throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
	}
1007304
private function _writeHyperlinks(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null)
	{
		// Hyperlink collection
		$hyperlinkCollection = $pSheet->getHyperlinkCollection();

		// Relation ID
		$relationId = 1;

		// Write hyperlinks?
		if (!empty($hyperlinkCollection)) {
			$objWriter->startElement('hyperlinks');

			foreach ($hyperlinkCollection as $coordinate => $hyperlink) {
				$objWriter->startElement('hyperlink');

				$objWriter->writeAttribute('ref', $coordinate);
				if (!$hyperlink->isInternal()) {
					$objWriter->writeAttribute('r:id',	'rId_hyperlink_' . $relationId);
					++$relationId;
				} else {
					$objWriter->writeAttribute('location',	str_replace('sheet://', '', $hyperlink->getUrl()));
				}

				if ($hyperlink->getTooltip() != '') {
					$objWriter->writeAttribute('tooltip', $hyperlink->getTooltip());
				}

				$objWriter->endElement();
			}

			$objWriter->endElement();
		}
	}
564419
public function writeTheme(PHPExcel $pPHPExcel = null)
	{
			// 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');

			// a:theme
			$objWriter->startElement('a:theme');
			$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
			$objWriter->writeAttribute('name', 'Office Theme');

				// a:themeElements
				$objWriter->startElement('a:themeElements');

					// a:clrScheme
					$objWriter->startElement('a:clrScheme');
					$objWriter->writeAttribute('name', 'Office');

						// a:dk1
						$objWriter->startElement('a:dk1');

							// a:sysClr
							$objWriter->startElement('a:sysClr');
							$objWriter->writeAttribute('val', 'windowText');
							$objWriter->writeAttribute('lastClr', '000000');
							$objWriter->endElement();

						$objWriter->endElement();

						// a:lt1
						$objWriter->startElement('a:lt1');

							// a:sysClr
							$objWriter->startElement('a:sysClr');
							$objWriter->writeAttribute('val', 'window');
							$objWriter->writeAttribute('lastClr', 'FFFFFF');
							$objWriter->endElement();

						$objWriter->endElement();

						// a:dk2
						$this->_writeColourScheme($objWriter);

					$objWriter->endElement();

					// a:fontScheme
					$objWriter->startElement('a:fontScheme');
					$objWriter->writeAttribute('name', 'Office');

						// a:majorFont
						$objWriter->startElement('a:majorFont');
							$this->_writeFonts($objWriter, 'Cambria', self::$_majorFonts);
						$objWriter->endElement();

						// a:minorFont
						$objWriter->startElement('a:minorFont');
							$this->_writeFonts($objWriter, 'Calibri', self::$_minorFonts);
						$objWriter->endElement();

					$objWriter->endElement();

					// a:fmtScheme
					$objWriter->startElement('a:fmtScheme');
					$objWriter->writeAttribute('name', 'Office');

						// a:fillStyleLst
						$objWriter->startElement('a:fillStyleLst');

							// a:solidFill
							$objWriter->startElement('a:solidFill');

								// a:schemeClr
								$objWriter->startElement('a:schemeClr');
								$objWriter->writeAttribute('val', 'phClr');
								$objWriter->endElement();

							$objWriter->endElement();

							// a:gradFill
							$objWriter->startElement('a:gradFill');
							$objWriter->writeAttribute('rotWithShape', '1');

								// a:gsLst
								$objWriter->startElement('a:gsLst');

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '0');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:tint
											$objWriter->startElement('a:tint');
											$objWriter->writeAttribute('val', '50000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '300000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '35000');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:tint
											$objWriter->startElement('a:tint');
											$objWriter->writeAttribute('val', '37000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '300000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '100000');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:tint
											$objWriter->startElement('a:tint');
											$objWriter->writeAttribute('val', '15000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '350000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

								// a:lin
								$objWriter->startElement('a:lin');
								$objWriter->writeAttribute('ang', '16200000');
								$objWriter->writeAttribute('scaled', '1');
								$objWriter->endElement();

							$objWriter->endElement();

							// a:gradFill
							$objWriter->startElement('a:gradFill');
							$objWriter->writeAttribute('rotWithShape', '1');

								// a:gsLst
								$objWriter->startElement('a:gsLst');

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '0');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:shade
											$objWriter->startElement('a:shade');
											$objWriter->writeAttribute('val', '51000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '130000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '80000');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:shade
											$objWriter->startElement('a:shade');
											$objWriter->writeAttribute('val', '93000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '130000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '100000');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:shade
											$objWriter->startElement('a:shade');
											$objWriter->writeAttribute('val', '94000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '135000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

								// a:lin
								$objWriter->startElement('a:lin');
								$objWriter->writeAttribute('ang', '16200000');
								$objWriter->writeAttribute('scaled', '0');
								$objWriter->endElement();

							$objWriter->endElement();

						$objWriter->endElement();

						// a:lnStyleLst
						$objWriter->startElement('a:lnStyleLst');

							// a:ln
							$objWriter->startElement('a:ln');
							$objWriter->writeAttribute('w', '9525');
							$objWriter->writeAttribute('cap', 'flat');
							$objWriter->writeAttribute('cmpd', 'sng');
							$objWriter->writeAttribute('algn', 'ctr');

								// a:solidFill
								$objWriter->startElement('a:solidFill');

									// a:schemeClr
									$objWriter->startElement('a:schemeClr');
									$objWriter->writeAttribute('val', 'phClr');

											// a:shade
											$objWriter->startElement('a:shade');
											$objWriter->writeAttribute('val', '95000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '105000');
											$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

								// a:prstDash
								$objWriter->startElement('a:prstDash');
								$objWriter->writeAttribute('val', 'solid');
								$objWriter->endElement();

							$objWriter->endElement();

							// a:ln
							$objWriter->startElement('a:ln');
							$objWriter->writeAttribute('w', '25400');
							$objWriter->writeAttribute('cap', 'flat');
							$objWriter->writeAttribute('cmpd', 'sng');
							$objWriter->writeAttribute('algn', 'ctr');

								// a:solidFill
								$objWriter->startElement('a:solidFill');

									// a:schemeClr
									$objWriter->startElement('a:schemeClr');
									$objWriter->writeAttribute('val', 'phClr');
									$objWriter->endElement();

								$objWriter->endElement();

								// a:prstDash
								$objWriter->startElement('a:prstDash');
								$objWriter->writeAttribute('val', 'solid');
								$objWriter->endElement();

							$objWriter->endElement();

							// a:ln
							$objWriter->startElement('a:ln');
							$objWriter->writeAttribute('w', '38100');
							$objWriter->writeAttribute('cap', 'flat');
							$objWriter->writeAttribute('cmpd', 'sng');
							$objWriter->writeAttribute('algn', 'ctr');

								// a:solidFill
								$objWriter->startElement('a:solidFill');

									// a:schemeClr
									$objWriter->startElement('a:schemeClr');
									$objWriter->writeAttribute('val', 'phClr');
									$objWriter->endElement();

								$objWriter->endElement();

								// a:prstDash
								$objWriter->startElement('a:prstDash');
								$objWriter->writeAttribute('val', 'solid');
								$objWriter->endElement();

							$objWriter->endElement();

						$objWriter->endElement();



						// a:effectStyleLst
						$objWriter->startElement('a:effectStyleLst');

							// a:effectStyle
							$objWriter->startElement('a:effectStyle');

								// a:effectLst
								$objWriter->startElement('a:effectLst');

									// a:outerShdw
									$objWriter->startElement('a:outerShdw');
									$objWriter->writeAttribute('blurRad', '40000');
									$objWriter->writeAttribute('dist', '20000');
									$objWriter->writeAttribute('dir', '5400000');
									$objWriter->writeAttribute('rotWithShape', '0');

										// a:srgbClr
										$objWriter->startElement('a:srgbClr');
										$objWriter->writeAttribute('val', '000000');

											// a:alpha
											$objWriter->startElement('a:alpha');
											$objWriter->writeAttribute('val', '38000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

							$objWriter->endElement();

							// a:effectStyle
							$objWriter->startElement('a:effectStyle');

								// a:effectLst
								$objWriter->startElement('a:effectLst');

									// a:outerShdw
									$objWriter->startElement('a:outerShdw');
									$objWriter->writeAttribute('blurRad', '40000');
									$objWriter->writeAttribute('dist', '23000');
									$objWriter->writeAttribute('dir', '5400000');
									$objWriter->writeAttribute('rotWithShape', '0');

										// a:srgbClr
										$objWriter->startElement('a:srgbClr');
										$objWriter->writeAttribute('val', '000000');

											// a:alpha
											$objWriter->startElement('a:alpha');
											$objWriter->writeAttribute('val', '35000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

							$objWriter->endElement();

							// a:effectStyle
							$objWriter->startElement('a:effectStyle');

								// a:effectLst
								$objWriter->startElement('a:effectLst');

									// a:outerShdw
									$objWriter->startElement('a:outerShdw');
									$objWriter->writeAttribute('blurRad', '40000');
									$objWriter->writeAttribute('dist', '23000');
									$objWriter->writeAttribute('dir', '5400000');
									$objWriter->writeAttribute('rotWithShape', '0');

										// a:srgbClr
										$objWriter->startElement('a:srgbClr');
										$objWriter->writeAttribute('val', '000000');

											// a:alpha
											$objWriter->startElement('a:alpha');
											$objWriter->writeAttribute('val', '35000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

								// a:scene3d
								$objWriter->startElement('a:scene3d');

									// a:camera
									$objWriter->startElement('a:camera');
									$objWriter->writeAttribute('prst', 'orthographicFront');

										// a:rot
										$objWriter->startElement('a:rot');
										$objWriter->writeAttribute('lat', '0');
										$objWriter->writeAttribute('lon', '0');
										$objWriter->writeAttribute('rev', '0');
										$objWriter->endElement();

									$objWriter->endElement();

									// a:lightRig
									$objWriter->startElement('a:lightRig');
									$objWriter->writeAttribute('rig', 'threePt');
									$objWriter->writeAttribute('dir', 't');

										// a:rot
										$objWriter->startElement('a:rot');
										$objWriter->writeAttribute('lat', '0');
										$objWriter->writeAttribute('lon', '0');
										$objWriter->writeAttribute('rev', '1200000');
										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

								// a:sp3d
								$objWriter->startElement('a:sp3d');

									// a:bevelT
									$objWriter->startElement('a:bevelT');
									$objWriter->writeAttribute('w', '63500');
									$objWriter->writeAttribute('h', '25400');
									$objWriter->endElement();

								$objWriter->endElement();

							$objWriter->endElement();

						$objWriter->endElement();

						// a:bgFillStyleLst
						$objWriter->startElement('a:bgFillStyleLst');

							// a:solidFill
							$objWriter->startElement('a:solidFill');

								// a:schemeClr
								$objWriter->startElement('a:schemeClr');
								$objWriter->writeAttribute('val', 'phClr');
								$objWriter->endElement();

							$objWriter->endElement();

							// a:gradFill
							$objWriter->startElement('a:gradFill');
							$objWriter->writeAttribute('rotWithShape', '1');

								// a:gsLst
								$objWriter->startElement('a:gsLst');

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '0');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:tint
											$objWriter->startElement('a:tint');
											$objWriter->writeAttribute('val', '40000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '350000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '40000');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:tint
											$objWriter->startElement('a:tint');
											$objWriter->writeAttribute('val', '45000');
											$objWriter->endElement();

											// a:shade
											$objWriter->startElement('a:shade');
											$objWriter->writeAttribute('val', '99000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '350000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '100000');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:shade
											$objWriter->startElement('a:shade');
											$objWriter->writeAttribute('val', '20000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '255000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

								// a:path
								$objWriter->startElement('a:path');
								$objWriter->writeAttribute('path', 'circle');

									// a:fillToRect
									$objWriter->startElement('a:fillToRect');
									$objWriter->writeAttribute('l', '50000');
									$objWriter->writeAttribute('t', '-80000');
									$objWriter->writeAttribute('r', '50000');
									$objWriter->writeAttribute('b', '180000');
									$objWriter->endElement();

								$objWriter->endElement();

							$objWriter->endElement();

							// a:gradFill
							$objWriter->startElement('a:gradFill');
							$objWriter->writeAttribute('rotWithShape', '1');

								// a:gsLst
								$objWriter->startElement('a:gsLst');

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '0');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:tint
											$objWriter->startElement('a:tint');
											$objWriter->writeAttribute('val', '80000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '300000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

									// a:gs
									$objWriter->startElement('a:gs');
									$objWriter->writeAttribute('pos', '100000');

										// a:schemeClr
										$objWriter->startElement('a:schemeClr');
										$objWriter->writeAttribute('val', 'phClr');

											// a:shade
											$objWriter->startElement('a:shade');
											$objWriter->writeAttribute('val', '30000');
											$objWriter->endElement();

											// a:satMod
											$objWriter->startElement('a:satMod');
											$objWriter->writeAttribute('val', '200000');
											$objWriter->endElement();

										$objWriter->endElement();

									$objWriter->endElement();

								$objWriter->endElement();

								// a:path
								$objWriter->startElement('a:path');
								$objWriter->writeAttribute('path', 'circle');

									// a:fillToRect
									$objWriter->startElement('a:fillToRect');
									$objWriter->writeAttribute('l', '50000');
									$objWriter->writeAttribute('t', '50000');
									$objWriter->writeAttribute('r', '50000');
									$objWriter->writeAttribute('b', '50000');
									$objWriter->endElement();

								$objWriter->endElement();

							$objWriter->endElement();

						$objWriter->endElement();

					$objWriter->endElement();

				$objWriter->endElement();

				// a:objectDefaults
				$objWriter->writeElement('a:objectDefaults', null);

				// a:extraClrSchemeLst
				$objWriter->writeElement('a:extraClrSchemeLst', null);

			$objWriter->endElement();

			// Return
			return $objWriter->getData();
	}
746774
private function _writeSheetData(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pStringTable = null)
	{
		if (is_array($pStringTable)) {
			// Flipped stringtable, for faster index searching
			$aFlippedStringTable = $this->getParentWriter()->getWriterPart('stringtable')->flipStringTable($pStringTable);

			// sheetData
			$objWriter->startElement('sheetData');

				// Get column count
				$colCount = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn());

				// Highest row number
				$highestRow = $pSheet->getHighestRow();

				// Loop through cells
				$cellsByRow = array();
				foreach ($pSheet->getCellCollection() as $cellID) {
					$cellAddress = PHPExcel_Cell::coordinateFromString($cellID);
					$cellsByRow[$cellAddress[1]][] = $cellID;
				}

				$currentRow = 0;
				while($currentRow++ < $highestRow) {
					// Get row dimension
					$rowDimension = $pSheet->getRowDimension($currentRow);

					// Write current row?
					$writeCurrentRow =	isset($cellsByRow[$currentRow]) ||
										$rowDimension->getRowHeight() >= 0 ||
										$rowDimension->getVisible() == false ||
										$rowDimension->getCollapsed() == true ||
										$rowDimension->getOutlineLevel() > 0 ||
										$rowDimension->getXfIndex() !== null;

					if ($writeCurrentRow) {
						// Start a new row
						$objWriter->startElement('row');
						$objWriter->writeAttribute('r',	$currentRow);
						$objWriter->writeAttribute('spans',	'1:' . $colCount);

						// Row dimensions
						if ($rowDimension->getRowHeight() >= 0) {
							$objWriter->writeAttribute('customHeight',	'1');
							$objWriter->writeAttribute('ht',			PHPExcel_Shared_String::FormatNumber($rowDimension->getRowHeight()));
						}

						// Row visibility
						if ($rowDimension->getVisible() == false) {
							$objWriter->writeAttribute('hidden',		'true');
						}

						// Collapsed
						if ($rowDimension->getCollapsed() == true) {
							$objWriter->writeAttribute('collapsed',		'true');
						}

						// Outline level
						if ($rowDimension->getOutlineLevel() > 0) {
							$objWriter->writeAttribute('outlineLevel',	$rowDimension->getOutlineLevel());
						}

						// Style
						if ($rowDimension->getXfIndex() !== null) {
							$objWriter->writeAttribute('s',	$rowDimension->getXfIndex());
							$objWriter->writeAttribute('customFormat', '1');
						}

						// Write cells
						if (isset($cellsByRow[$currentRow])) {
							foreach($cellsByRow[$currentRow] as $cellAddress) {
								// Write cell
								$this->_writeCell($objWriter, $pSheet, $cellAddress, $pStringTable, $aFlippedStringTable);
							}
						}

						// End row
						$objWriter->endElement();
					}
				}

			$objWriter->endElement();
		} else {
			throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
		}
	}
1090113
private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) {
		// Construct HTML
		$html = '';

		// Write images
		foreach ($pSheet->getDrawingCollection() as $drawing) {
			if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
				if ($drawing->getCoordinates() == $coordinates) {
					$filename = $drawing->getPath();

					// Strip off eventual '.'
					if (substr($filename, 0, 1) == '.') {
						$filename = substr($filename, 1);
					}

					// Prepend images root
					$filename = $this->getImagesRoot() . $filename;

					// Strip off eventual '.'
					if (substr($filename, 0, 1) == '.' && substr($filename, 0, 2) != './') {
						$filename = substr($filename, 1);
					}

					// Convert UTF8 data to PCDATA
					$filename = htmlspecialchars($filename);

					$html .= PHP_EOL;
					if ((!$this->_embedImages) || ($this->_isPdf)) {
						$imageData = $filename;
					} else {
						$imageDetails = getimagesize($filename);
						if ($fp = fopen($filename,"rb", 0)) {
							$picture = fread($fp,filesize($filename));
							fclose($fp);
							// base64 encode the binary data, then break it
							// into chunks according to RFC 2045 semantics
							$base64 = chunk_split(base64_encode($picture));
							$imageData = 'data:'.$imageDetails['mime'].';base64,' . $base64;
						} else {
							$imageData = $filename;
						}
					}

					$html .= '<div style="position: relative;">';
					$html .= '<img style="position: absolute; z-index: 1; left: ' . 
                        $drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: ' . 
                        $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="' . 
                        $imageData . '" border="0" />';
					$html .= '</div>';
				}
			}
		}

		// Return
		return $html;
	}
301124
private function writeCellStyleDxf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null)
    {
        // dxf
        $objWriter->startElement('dxf');

        // font
        $this->writeFont($objWriter, $pStyle->getFont());

        // numFmt
        $this->writeNumFmt($objWriter, $pStyle->getNumberFormat());

        // fill
        $this->writeFill($objWriter, $pStyle->getFill());

        // alignment
        $objWriter->startElement('alignment');
        if ($pStyle->getAlignment()->getHorizontal() !== null) {
            $objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
        }
        if ($pStyle->getAlignment()->getVertical() !== null) {
            $objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
        }

        if ($pStyle->getAlignment()->getTextRotation() !== null) {
            $textRotation = 0;
            if ($pStyle->getAlignment()->getTextRotation() >= 0) {
                $textRotation = $pStyle->getAlignment()->getTextRotation();
            } elseif ($pStyle->getAlignment()->getTextRotation() < 0) {
                $textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
            }
            $objWriter->writeAttribute('textRotation', $textRotation);
        }
        $objWriter->endElement();

        // border
        $this->writeBorder($objWriter, $pStyle->getBorders());

        // protection
        if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) {
            if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
                $pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
                $objWriter->startElement('protection');
                if (($pStyle->getProtection()->getLocked() !== null) &&
                    ($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() !== null) &&
                    ($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();
    }
303878
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
	{
		$lineEnding = ini_get('auto_detect_line_endings');
		ini_set('auto_detect_line_endings', true);

		// Open file
		$this->_openFile($pFilename);
		if (!$this->_isValidFormat()) {
			fclose ($this->_fileHandle);
			throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
		}
		$fileHandle = $this->_fileHandle;

		// Skip BOM, if any
		$this->_skipBOM();

		// Create new PHPExcel object
		while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
			$objPHPExcel->createSheet();
		}
		$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);

		$escapeEnclosures = array( "\\" . $this->_enclosure,
								   $this->_enclosure . $this->_enclosure
								 );

		// Set our starting row based on whether we're in contiguous mode or not
		$currentRow = 1;
		if ($this->_contiguous) {
			$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
		}

		// Loop through each line of the file in turn
		while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
			$columnLetter = 'A';
			foreach($rowData as $rowDatum) {
				if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
					// Unescape enclosures
					$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);

					// Convert encoding if necessary
					if ($this->_inputEncoding !== 'UTF-8') {
						$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
					}

					// Set cell value
					$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
				}
				++$columnLetter;
			}
			++$currentRow;
		}

		// Close file
		fclose($fileHandle);

		if ($this->_contiguous) {
			$this->_contiguousRow = $currentRow;
		}

		ini_set('auto_detect_line_endings', $lineEnding);

		// Return
		return $objPHPExcel;
	}
712337
public function writeContentTypes(PHPExcel $pPHPExcel = null, $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');

		// Types
		$objWriter->startElement('Types');
		$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');

			// Theme
			$this->_writeOverrideContentType(
				$objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
			);

			// Styles
			$this->_writeOverrideContentType(
				$objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
			);

			// Rels
			$this->_writeDefaultContentType(
				$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
			);

			// XML
			$this->_writeDefaultContentType(
				$objWriter, 'xml', 'application/xml'
			);

			// VML
			$this->_writeDefaultContentType(
				$objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'
			);

			// Workbook
			$this->_writeOverrideContentType(
				$objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
			);

			// DocProps
			$this->_writeOverrideContentType(
				$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
			);

			$this->_writeOverrideContentType(
				$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
			);

			$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
			if (!empty($customPropertyList)) {
				$this->_writeOverrideContentType(
					$objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
				);
			}

			// Worksheets
			$sheetCount = $pPHPExcel->getSheetCount();
			for ($i = 0; $i < $sheetCount; ++$i) {
				$this->_writeOverrideContentType(
					$objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
				);
			}

			// Shared strings
			$this->_writeOverrideContentType(
				$objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
			);

			// Add worksheet relationship content types
			$chart = 1;
			for ($i = 0; $i < $sheetCount; ++$i) {
				$drawings = $pPHPExcel->getSheet($i)->getDrawingCollection();
				$drawingCount = count($drawings);
				$chartCount = ($includeCharts) ? $pPHPExcel->getSheet($i)->getChartCount() : 0;

				//	We need a drawing relationship for the worksheet if we have either drawings or charts
				if (($drawingCount > 0) || ($chartCount > 0)) {
					$this->_writeOverrideContentType(
						$objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml'
					);
				}

				//	If we have charts, then we need a chart relationship for every individual chart
				if ($chartCount > 0) {
					for ($c = 0; $c < $chartCount; ++$c) {
						$this->_writeOverrideContentType(
							$objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'
						);
					}
				}
			}

			// Comments
			for ($i = 0; $i < $sheetCount; ++$i) {
				if (count($pPHPExcel->getSheet($i)->getComments()) > 0) {
					$this->_writeOverrideContentType(
						$objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
					);
				}
			}

			// Add media content-types
			$aMediaContentTypes = array();
			$mediaCount = $this->getParentWriter()->getDrawingHashTable()->count();
			for ($i = 0; $i < $mediaCount; ++$i) {
				$extension 	= '';
				$mimeType 	= '';

				if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
					$extension 	= strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
					$mimeType 	= $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
				} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
					$extension 	= strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
					$extension 	= explode('/', $extension);
					$extension 	= $extension[1];

					$mimeType 	= $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
				}

				if (!isset( $aMediaContentTypes[$extension]) ) {
						$aMediaContentTypes[$extension] = $mimeType;

						$this->_writeDefaultContentType(
							$objWriter, $extension, $mimeType
						);
				}
			}

			$sheetCount = $pPHPExcel->getSheetCount();
			for ($i = 0; $i < $sheetCount; ++$i) {
				if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) {
					foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) {
						if (!isset( $aMediaContentTypes[strtolower($image->getExtension())]) ) {
							$aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType( $image->getPath() );

							$this->_writeDefaultContentType(
								$objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]
							);
						}
					}
				}
			}

		$objWriter->endElement();

		// Return
		return $objWriter->getData();
	}
805206
private function _writeCellStyleDxf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null)
	{
		// dxf
		$objWriter->startElement('dxf');

			// font
			$this->_writeFont($objWriter, $pStyle->getFont());

			// numFmt
			$this->_writeNumFmt($objWriter, $pStyle->getNumberFormat());

			// fill
			$this->_writeFill($objWriter, $pStyle->getFill());

			// alignment
			$objWriter->startElement('alignment');
				if ($pStyle->getAlignment()->getHorizontal() !== NULL) {
					$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
				}
				if ($pStyle->getAlignment()->getVertical() !== NULL) {
					$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
				}

				if ($pStyle->getAlignment()->getTextRotation() !== NULL) {
					$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->endElement();

			// border
			$this->_writeBorder($objWriter, $pStyle->getBorders());

			// protection
			if (($pStyle->getProtection()->getLocked() !== NULL) ||
				($pStyle->getProtection()->getHidden() !== NULL)) {
				if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
					$pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
					$objWriter->startElement('protection');
						if (($pStyle->getProtection()->getLocked() !== NULL) &&
							($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() !== NULL) &&
							($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();
	}
880437
public function writeHeaderFooterDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null)
    {
        // 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');

        // Relationships
        $objWriter->startElement('Relationships');
        $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');

        // Loop through images and write relationships
        foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
            // Write relationship for image drawing
            $this->writeRelationship(
                $objWriter,
                $key,
                'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
                '../media/' . $value->getIndexedFilename()
            );
        }

        $objWriter->endElement();

        return $objWriter->getData();
    }