Add version files and new GIF images for UI components
This commit is contained in:
		| @ -0,0 +1,268 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_Comments | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Write comments to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet				$pWorksheet | ||||
| 	 * @return 	string 								XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeComments(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'); | ||||
|  | ||||
|   		// Comments cache | ||||
|   		$comments	= $pWorksheet->getComments(); | ||||
|  | ||||
|   		// Authors cache | ||||
|   		$authors	= array(); | ||||
|   		$authorId	= 0; | ||||
| 		foreach ($comments as $comment) { | ||||
| 			if (!isset($authors[$comment->getAuthor()])) { | ||||
| 				$authors[$comment->getAuthor()] = $authorId++; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// comments | ||||
| 		$objWriter->startElement('comments'); | ||||
| 		$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); | ||||
|  | ||||
| 			// Loop through authors | ||||
| 			$objWriter->startElement('authors'); | ||||
| 			foreach ($authors as $author => $index) { | ||||
| 				$objWriter->writeElement('author', $author); | ||||
| 			} | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Loop through comments | ||||
| 			$objWriter->startElement('commentList'); | ||||
| 			foreach ($comments as $key => $value) { | ||||
| 				$this->_writeComment($objWriter, $key, $value, $authors); | ||||
| 			} | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write comment to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter		$objWriter 			XML Writer | ||||
| 	 * @param	string							$pCellReference		Cell reference | ||||
| 	 * @param 	PHPExcel_Comment				$pComment			Comment | ||||
| 	 * @param	array							$pAuthors			Array of authors | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function _writeComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null, $pAuthors = null) | ||||
| 	{ | ||||
| 		// comment | ||||
| 		$objWriter->startElement('comment'); | ||||
| 		$objWriter->writeAttribute('ref', 		$pCellReference); | ||||
| 		$objWriter->writeAttribute('authorId', 	$pAuthors[$pComment->getAuthor()]); | ||||
|  | ||||
| 			// text | ||||
| 			$objWriter->startElement('text'); | ||||
| 			$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pComment->getText()); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write VML comments to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet				$pWorksheet | ||||
| 	 * @return 	string 								XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeVMLComments(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'); | ||||
|  | ||||
|   		// Comments cache | ||||
|   		$comments	= $pWorksheet->getComments(); | ||||
|  | ||||
| 		// xml | ||||
| 		$objWriter->startElement('xml'); | ||||
| 		$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); | ||||
| 		$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); | ||||
| 		$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); | ||||
|  | ||||
| 			// o:shapelayout | ||||
| 			$objWriter->startElement('o:shapelayout'); | ||||
| 			$objWriter->writeAttribute('v:ext', 		'edit'); | ||||
|  | ||||
| 				// o:idmap | ||||
| 				$objWriter->startElement('o:idmap'); | ||||
| 				$objWriter->writeAttribute('v:ext', 	'edit'); | ||||
| 				$objWriter->writeAttribute('data', 		'1'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// v:shapetype | ||||
| 			$objWriter->startElement('v:shapetype'); | ||||
| 			$objWriter->writeAttribute('id', 		'_x0000_t202'); | ||||
| 			$objWriter->writeAttribute('coordsize', '21600,21600'); | ||||
| 			$objWriter->writeAttribute('o:spt', 	'202'); | ||||
| 			$objWriter->writeAttribute('path', 		'm,l,21600r21600,l21600,xe'); | ||||
|  | ||||
| 				// v:stroke | ||||
| 				$objWriter->startElement('v:stroke'); | ||||
| 				$objWriter->writeAttribute('joinstyle', 	'miter'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// v:path | ||||
| 				$objWriter->startElement('v:path'); | ||||
| 				$objWriter->writeAttribute('gradientshapeok', 	't'); | ||||
| 				$objWriter->writeAttribute('o:connecttype', 	'rect'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Loop through comments | ||||
| 			foreach ($comments as $key => $value) { | ||||
| 				$this->_writeVMLComment($objWriter, $key, $value); | ||||
| 			} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write VML comment to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter		$objWriter 			XML Writer | ||||
| 	 * @param	string							$pCellReference		Cell reference | ||||
| 	 * @param 	PHPExcel_Comment				$pComment			Comment | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function _writeVMLComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null) | ||||
| 	{ | ||||
|  		// Metadata | ||||
|  		list($column, $row) = PHPExcel_Cell::coordinateFromString($pCellReference); | ||||
|  		$column = PHPExcel_Cell::columnIndexFromString($column); | ||||
|  		$id = 1024 + $column + $row; | ||||
|  		$id = substr($id, 0, 4); | ||||
|  | ||||
| 		// v:shape | ||||
| 		$objWriter->startElement('v:shape'); | ||||
| 		$objWriter->writeAttribute('id', 			'_x0000_s' . $id); | ||||
| 		$objWriter->writeAttribute('type', 			'#_x0000_t202'); | ||||
| 		$objWriter->writeAttribute('style', 		'position:absolute;margin-left:' . $pComment->getMarginLeft() . ';margin-top:' . $pComment->getMarginTop() . ';width:' . $pComment->getWidth() . ';height:' . $pComment->getHeight() . ';z-index:1;visibility:' . ($pComment->getVisible() ? 'visible' : 'hidden')); | ||||
| 		$objWriter->writeAttribute('fillcolor', 	'#' . $pComment->getFillColor()->getRGB()); | ||||
| 		$objWriter->writeAttribute('o:insetmode', 	'auto'); | ||||
|  | ||||
| 			// v:fill | ||||
| 			$objWriter->startElement('v:fill'); | ||||
| 			$objWriter->writeAttribute('color2', 		'#' . $pComment->getFillColor()->getRGB()); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// v:shadow | ||||
| 			$objWriter->startElement('v:shadow'); | ||||
| 			$objWriter->writeAttribute('on', 			't'); | ||||
| 			$objWriter->writeAttribute('color', 		'black'); | ||||
| 			$objWriter->writeAttribute('obscured', 		't'); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// v:path | ||||
| 			$objWriter->startElement('v:path'); | ||||
| 			$objWriter->writeAttribute('o:connecttype', 'none'); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// v:textbox | ||||
| 			$objWriter->startElement('v:textbox'); | ||||
| 			$objWriter->writeAttribute('style', 'mso-direction-alt:auto'); | ||||
|  | ||||
| 				// div | ||||
| 				$objWriter->startElement('div'); | ||||
| 				$objWriter->writeAttribute('style', 'text-align:left'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// x:ClientData | ||||
| 			$objWriter->startElement('x:ClientData'); | ||||
| 			$objWriter->writeAttribute('ObjectType', 'Note'); | ||||
|  | ||||
| 				// x:MoveWithCells | ||||
| 				$objWriter->writeElement('x:MoveWithCells', ''); | ||||
|  | ||||
| 				// x:SizeWithCells | ||||
| 				$objWriter->writeElement('x:SizeWithCells', ''); | ||||
|  | ||||
| 				// x:Anchor | ||||
| 				//$objWriter->writeElement('x:Anchor', $column . ', 15, ' . ($row - 2) . ', 10, ' . ($column + 4) . ', 15, ' . ($row + 5) . ', 18'); | ||||
|  | ||||
| 				// x:AutoFill | ||||
| 				$objWriter->writeElement('x:AutoFill', 'False'); | ||||
|  | ||||
| 				// x:Row | ||||
| 				$objWriter->writeElement('x:Row', ($row - 1)); | ||||
|  | ||||
| 				// x:Column | ||||
| 				$objWriter->writeElement('x:Column', ($column - 1)); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,245 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_ContentTypes | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Write content types to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel $pPHPExcel | ||||
| 	 * @return 	string 						XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeContentTypes(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'); | ||||
|  | ||||
| 		// 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 (count($customPropertyList) > 0) { | ||||
| 				$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 | ||||
| 			for ($i = 0; $i < $sheetCount; ++$i) { | ||||
| 				if ($pPHPExcel->getSheet($i)->getDrawingCollection()->count() > 0) { | ||||
| 					$this->_writeOverrideContentType( | ||||
| 						$objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+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(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get image mime type | ||||
| 	 * | ||||
| 	 * @param 	string	$pFile	Filename | ||||
| 	 * @return 	string	Mime Type | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _getImageMimeType($pFile = '') | ||||
| 	{ | ||||
| 		if (PHPExcel_Shared_File::file_exists($pFile)) { | ||||
| 			$image = getimagesize($pFile); | ||||
| 			return image_type_to_mime_type($image[2]); | ||||
| 		} else { | ||||
| 			throw new Exception("File $pFile does not exist"); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Default content type | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	string 						$pPartname 		Part name | ||||
| 	 * @param 	string 						$pContentType 	Content type | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeDefaultContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') | ||||
| 	{ | ||||
| 		if ($pPartname != '' && $pContentType != '') { | ||||
| 			// Write content type | ||||
| 			$objWriter->startElement('Default'); | ||||
| 			$objWriter->writeAttribute('Extension', 	$pPartname); | ||||
| 			$objWriter->writeAttribute('ContentType', 	$pContentType); | ||||
| 			$objWriter->endElement(); | ||||
| 		} else { | ||||
| 			throw new Exception("Invalid parameters passed."); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Override content type | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	string 						$pPartname 		Part name | ||||
| 	 * @param 	string 						$pContentType 	Content type | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeOverrideContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '') | ||||
| 	{ | ||||
| 		if ($pPartname != '' && $pContentType != '') { | ||||
| 			// Write content type | ||||
| 			$objWriter->startElement('Override'); | ||||
| 			$objWriter->writeAttribute('PartName', 		$pPartname); | ||||
| 			$objWriter->writeAttribute('ContentType', 	$pContentType); | ||||
| 			$objWriter->endElement(); | ||||
| 		} else { | ||||
| 			throw new Exception("Invalid parameters passed."); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,272 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_DocProps | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| /** | ||||
| 	 * Write docProps/app.xml to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel	$pPHPExcel | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeDocPropsApp(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'); | ||||
|  | ||||
| 		// Properties | ||||
| 		$objWriter->startElement('Properties'); | ||||
| 			$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); | ||||
| 			$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); | ||||
|  | ||||
| 			// Application | ||||
| 			$objWriter->writeElement('Application', 	'Microsoft Excel'); | ||||
|  | ||||
| 			// DocSecurity | ||||
| 			$objWriter->writeElement('DocSecurity', 	'0'); | ||||
|  | ||||
| 			// ScaleCrop | ||||
| 			$objWriter->writeElement('ScaleCrop', 		'false'); | ||||
|  | ||||
| 			// HeadingPairs | ||||
| 			$objWriter->startElement('HeadingPairs'); | ||||
|  | ||||
| 				// Vector | ||||
| 				$objWriter->startElement('vt:vector'); | ||||
| 					$objWriter->writeAttribute('size', 		'2'); | ||||
| 					$objWriter->writeAttribute('baseType', 	'variant'); | ||||
|  | ||||
| 					// Variant | ||||
| 					$objWriter->startElement('vt:variant'); | ||||
| 						$objWriter->writeElement('vt:lpstr', 	'Worksheets'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// Variant | ||||
| 					$objWriter->startElement('vt:variant'); | ||||
| 						$objWriter->writeElement('vt:i4', 		$pPHPExcel->getSheetCount()); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// TitlesOfParts | ||||
| 			$objWriter->startElement('TitlesOfParts'); | ||||
|  | ||||
| 				// Vector | ||||
| 				$objWriter->startElement('vt:vector'); | ||||
| 					$objWriter->writeAttribute('size', 		$pPHPExcel->getSheetCount()); | ||||
| 					$objWriter->writeAttribute('baseType',	'lpstr'); | ||||
|  | ||||
| 					$sheetCount = $pPHPExcel->getSheetCount(); | ||||
| 					for ($i = 0; $i < $sheetCount; ++$i) { | ||||
| 						$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle()); | ||||
| 					} | ||||
|  | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Company | ||||
| 			$objWriter->writeElement('Company', 			$pPHPExcel->getProperties()->getCompany()); | ||||
|  | ||||
| 			// Company | ||||
| 			$objWriter->writeElement('Manager', 			$pPHPExcel->getProperties()->getManager()); | ||||
|  | ||||
| 			// LinksUpToDate | ||||
| 			$objWriter->writeElement('LinksUpToDate', 		'false'); | ||||
|  | ||||
| 			// SharedDoc | ||||
| 			$objWriter->writeElement('SharedDoc', 			'false'); | ||||
|  | ||||
| 			// HyperlinksChanged | ||||
| 			$objWriter->writeElement('HyperlinksChanged', 	'false'); | ||||
|  | ||||
| 			// AppVersion | ||||
| 			$objWriter->writeElement('AppVersion', 			'12.0000'); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write docProps/core.xml to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel	$pPHPExcel | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeDocPropsCore(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'); | ||||
|  | ||||
| 		// cp:coreProperties | ||||
| 		$objWriter->startElement('cp:coreProperties'); | ||||
| 			$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); | ||||
| 			$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); | ||||
| 			$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); | ||||
| 			$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); | ||||
| 			$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); | ||||
|  | ||||
| 			// dc:creator | ||||
| 			$objWriter->writeElement('dc:creator',			$pPHPExcel->getProperties()->getCreator()); | ||||
|  | ||||
| 			// cp:lastModifiedBy | ||||
| 			$objWriter->writeElement('cp:lastModifiedBy', 	$pPHPExcel->getProperties()->getLastModifiedBy()); | ||||
|  | ||||
| 			// dcterms:created | ||||
| 			$objWriter->startElement('dcterms:created'); | ||||
| 				$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); | ||||
| 				$objWriter->writeRawData(date(DATE_W3C, 	$pPHPExcel->getProperties()->getCreated())); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// dcterms:modified | ||||
| 			$objWriter->startElement('dcterms:modified'); | ||||
| 				$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); | ||||
| 				$objWriter->writeRawData(date(DATE_W3C, 	$pPHPExcel->getProperties()->getModified())); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// dc:title | ||||
| 			$objWriter->writeElement('dc:title', 			$pPHPExcel->getProperties()->getTitle()); | ||||
|  | ||||
| 			// dc:description | ||||
| 			$objWriter->writeElement('dc:description', 		$pPHPExcel->getProperties()->getDescription()); | ||||
|  | ||||
| 			// dc:subject | ||||
| 			$objWriter->writeElement('dc:subject', 			$pPHPExcel->getProperties()->getSubject()); | ||||
|  | ||||
| 			// cp:keywords | ||||
| 			$objWriter->writeElement('cp:keywords', 		$pPHPExcel->getProperties()->getKeywords()); | ||||
|  | ||||
| 			// cp:category | ||||
| 			$objWriter->writeElement('cp:category', 		$pPHPExcel->getProperties()->getCategory()); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write docProps/custom.xml to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel	$pPHPExcel | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeDocPropsCustom(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); | ||||
| 		if (count($customPropertyList) == 0) { | ||||
| 			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(); | ||||
| 	} | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,513 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_Drawing | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Write drawings to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet				$pWorksheet | ||||
| 	 * @return 	string 								XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeDrawings(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'); | ||||
|  | ||||
| 		// 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; | ||||
| 			} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write drawings to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Worksheet_BaseDrawing		$pDrawing | ||||
| 	 * @param 	int									$pRelationId | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function _writeDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet_BaseDrawing $pDrawing = null, $pRelationId = -1) | ||||
| 	{ | ||||
| 		if ($pRelationId >= 0) { | ||||
| 			// xdr:oneCellAnchor | ||||
| 			$objWriter->startElement('xdr:oneCellAnchor'); | ||||
| 				// Image location | ||||
| 				$aCoordinates 		= PHPExcel_Cell::coordinateFromString($pDrawing->getCoordinates()); | ||||
| 				$aCoordinates[0] 	= PHPExcel_Cell::columnIndexFromString($aCoordinates[0]); | ||||
|  | ||||
| 				// xdr:from | ||||
| 				$objWriter->startElement('xdr:from'); | ||||
| 					$objWriter->writeElement('xdr:col', $aCoordinates[0] - 1); | ||||
| 					$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetX())); | ||||
| 					$objWriter->writeElement('xdr:row', $aCoordinates[1] - 1); | ||||
| 					$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetY())); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// xdr:ext | ||||
| 				$objWriter->startElement('xdr:ext'); | ||||
| 					$objWriter->writeAttribute('cx', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getWidth())); | ||||
| 					$objWriter->writeAttribute('cy', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getHeight())); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// xdr:pic | ||||
| 				$objWriter->startElement('xdr:pic'); | ||||
|  | ||||
| 					// xdr:nvPicPr | ||||
| 					$objWriter->startElement('xdr:nvPicPr'); | ||||
|  | ||||
| 						// xdr:cNvPr | ||||
| 						$objWriter->startElement('xdr:cNvPr'); | ||||
| 						$objWriter->writeAttribute('id', $pRelationId); | ||||
| 						$objWriter->writeAttribute('name', $pDrawing->getName()); | ||||
| 						$objWriter->writeAttribute('descr', $pDrawing->getDescription()); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// xdr:cNvPicPr | ||||
| 						$objWriter->startElement('xdr:cNvPicPr'); | ||||
|  | ||||
| 							// a:picLocks | ||||
| 							$objWriter->startElement('a:picLocks'); | ||||
| 							$objWriter->writeAttribute('noChangeAspect', '1'); | ||||
| 							$objWriter->endElement(); | ||||
|  | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// xdr:blipFill | ||||
| 					$objWriter->startElement('xdr:blipFill'); | ||||
|  | ||||
| 						// a:blip | ||||
| 						$objWriter->startElement('a:blip'); | ||||
| 						$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); | ||||
| 						$objWriter->writeAttribute('r:embed', 'rId' . $pRelationId); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// a:stretch | ||||
| 						$objWriter->startElement('a:stretch'); | ||||
| 							$objWriter->writeElement('a:fillRect', null); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// xdr:spPr | ||||
| 					$objWriter->startElement('xdr:spPr'); | ||||
|  | ||||
| 						// a:xfrm | ||||
| 						$objWriter->startElement('a:xfrm'); | ||||
| 						$objWriter->writeAttribute('rot', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getRotation())); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// a:prstGeom | ||||
| 						$objWriter->startElement('a:prstGeom'); | ||||
| 						$objWriter->writeAttribute('prst', 'rect'); | ||||
|  | ||||
| 							// a:avLst | ||||
| 							$objWriter->writeElement('a:avLst', null); | ||||
|  | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| //						// a:solidFill | ||||
| //						$objWriter->startElement('a:solidFill'); | ||||
|  | ||||
| //							// a:srgbClr | ||||
| //							$objWriter->startElement('a:srgbClr'); | ||||
| //							$objWriter->writeAttribute('val', 'FFFFFF'); | ||||
|  | ||||
| ///* SHADE | ||||
| //								// a:shade | ||||
| //								$objWriter->startElement('a:shade'); | ||||
| //								$objWriter->writeAttribute('val', '85000'); | ||||
| //								$objWriter->endElement(); | ||||
| //*/ | ||||
|  | ||||
| //							$objWriter->endElement(); | ||||
|  | ||||
| //						$objWriter->endElement(); | ||||
| /* | ||||
| 						// a:ln | ||||
| 						$objWriter->startElement('a:ln'); | ||||
| 						$objWriter->writeAttribute('w', '88900'); | ||||
| 						$objWriter->writeAttribute('cap', 'sq'); | ||||
|  | ||||
| 							// a:solidFill | ||||
| 							$objWriter->startElement('a:solidFill'); | ||||
|  | ||||
| 								// a:srgbClr | ||||
| 								$objWriter->startElement('a:srgbClr'); | ||||
| 								$objWriter->writeAttribute('val', 'FFFFFF'); | ||||
| 								$objWriter->endElement(); | ||||
|  | ||||
| 							$objWriter->endElement(); | ||||
|  | ||||
| 							// a:miter | ||||
| 							$objWriter->startElement('a:miter'); | ||||
| 							$objWriter->writeAttribute('lim', '800000'); | ||||
| 							$objWriter->endElement(); | ||||
|  | ||||
| 						$objWriter->endElement(); | ||||
| */ | ||||
|  | ||||
| 						if ($pDrawing->getShadow()->getVisible()) { | ||||
| 							// a:effectLst | ||||
| 							$objWriter->startElement('a:effectLst'); | ||||
|  | ||||
| 								// a:outerShdw | ||||
| 								$objWriter->startElement('a:outerShdw'); | ||||
| 								$objWriter->writeAttribute('blurRad', 		PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getBlurRadius())); | ||||
| 								$objWriter->writeAttribute('dist',			PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getDistance())); | ||||
| 								$objWriter->writeAttribute('dir',			PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getShadow()->getDirection())); | ||||
| 								$objWriter->writeAttribute('algn',			$pDrawing->getShadow()->getAlignment()); | ||||
| 								$objWriter->writeAttribute('rotWithShape', 	'0'); | ||||
|  | ||||
| 									// a:srgbClr | ||||
| 									$objWriter->startElement('a:srgbClr'); | ||||
| 									$objWriter->writeAttribute('val',		$pDrawing->getShadow()->getColor()->getRGB()); | ||||
|  | ||||
| 										// a:alpha | ||||
| 										$objWriter->startElement('a:alpha'); | ||||
| 										$objWriter->writeAttribute('val', 	$pDrawing->getShadow()->getAlpha() * 1000); | ||||
| 										$objWriter->endElement(); | ||||
|  | ||||
| 									$objWriter->endElement(); | ||||
|  | ||||
| 								$objWriter->endElement(); | ||||
|  | ||||
| 							$objWriter->endElement(); | ||||
| 						} | ||||
| /* | ||||
|  | ||||
| 						// a:scene3d | ||||
| 						$objWriter->startElement('a:scene3d'); | ||||
|  | ||||
| 							// a:camera | ||||
| 							$objWriter->startElement('a:camera'); | ||||
| 							$objWriter->writeAttribute('prst', 'orthographicFront'); | ||||
| 							$objWriter->endElement(); | ||||
|  | ||||
| 							// a:lightRig | ||||
| 							$objWriter->startElement('a:lightRig'); | ||||
| 							$objWriter->writeAttribute('rig', 'twoPt'); | ||||
| 							$objWriter->writeAttribute('dir', 't'); | ||||
|  | ||||
| 								// a:rot | ||||
| 								$objWriter->startElement('a:rot'); | ||||
| 								$objWriter->writeAttribute('lat', '0'); | ||||
| 								$objWriter->writeAttribute('lon', '0'); | ||||
| 								$objWriter->writeAttribute('rev', '0'); | ||||
| 								$objWriter->endElement(); | ||||
|  | ||||
| 							$objWriter->endElement(); | ||||
|  | ||||
| 						$objWriter->endElement(); | ||||
| */ | ||||
| /* | ||||
| 						// a:sp3d | ||||
| 						$objWriter->startElement('a:sp3d'); | ||||
|  | ||||
| 							// a:bevelT | ||||
| 							$objWriter->startElement('a:bevelT'); | ||||
| 							$objWriter->writeAttribute('w', '25400'); | ||||
| 							$objWriter->writeAttribute('h', '19050'); | ||||
| 							$objWriter->endElement(); | ||||
|  | ||||
| 							// a:contourClr | ||||
| 							$objWriter->startElement('a:contourClr'); | ||||
|  | ||||
| 								// a:srgbClr | ||||
| 								$objWriter->startElement('a:srgbClr'); | ||||
| 								$objWriter->writeAttribute('val', 'FFFFFF'); | ||||
| 								$objWriter->endElement(); | ||||
|  | ||||
| 							$objWriter->endElement(); | ||||
|  | ||||
| 						$objWriter->endElement(); | ||||
| */ | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// xdr:clientData | ||||
| 				$objWriter->writeElement('xdr:clientData', null); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
| 		} else { | ||||
| 			throw new Exception("Invalid parameters passed."); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write VML header/footer images to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet				$pWorksheet | ||||
| 	 * @return 	string 								XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeVMLHeaderFooterImages(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'); | ||||
|  | ||||
|   		// Header/footer images | ||||
|   		$images = $pWorksheet->getHeaderFooter()->getImages(); | ||||
|  | ||||
| 		// xml | ||||
| 		$objWriter->startElement('xml'); | ||||
| 		$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml'); | ||||
| 		$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office'); | ||||
| 		$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel'); | ||||
|  | ||||
| 			// o:shapelayout | ||||
| 			$objWriter->startElement('o:shapelayout'); | ||||
| 			$objWriter->writeAttribute('v:ext', 		'edit'); | ||||
|  | ||||
| 				// o:idmap | ||||
| 				$objWriter->startElement('o:idmap'); | ||||
| 				$objWriter->writeAttribute('v:ext', 	'edit'); | ||||
| 				$objWriter->writeAttribute('data', 		'1'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// v:shapetype | ||||
| 			$objWriter->startElement('v:shapetype'); | ||||
| 			$objWriter->writeAttribute('id', 					'_x0000_t75'); | ||||
| 			$objWriter->writeAttribute('coordsize', 			'21600,21600'); | ||||
| 			$objWriter->writeAttribute('o:spt', 				'75'); | ||||
| 			$objWriter->writeAttribute('o:preferrelative', 		't'); | ||||
| 			$objWriter->writeAttribute('path', 					'm@4@5l@4@11@9@11@9@5xe'); | ||||
| 			$objWriter->writeAttribute('filled',		 		'f'); | ||||
| 			$objWriter->writeAttribute('stroked',		 		'f'); | ||||
|  | ||||
| 				// v:stroke | ||||
| 				$objWriter->startElement('v:stroke'); | ||||
| 				$objWriter->writeAttribute('joinstyle', 		'miter'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// v:formulas | ||||
| 				$objWriter->startElement('v:formulas'); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'if lineDrawn pixelLineWidth 0'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'sum @0 1 0'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'sum 0 0 @1'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'prod @2 1 2'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'prod @3 21600 pixelWidth'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'prod @3 21600 pixelHeight'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'sum @0 0 1'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'prod @6 1 2'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'prod @7 21600 pixelWidth'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'sum @8 21600 0'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'prod @7 21600 pixelHeight'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 					// v:f | ||||
| 					$objWriter->startElement('v:f'); | ||||
| 					$objWriter->writeAttribute('eqn', 		'sum @10 21600 0'); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// v:path | ||||
| 				$objWriter->startElement('v:path'); | ||||
| 				$objWriter->writeAttribute('o:extrusionok', 	'f'); | ||||
| 				$objWriter->writeAttribute('gradientshapeok', 	't'); | ||||
| 				$objWriter->writeAttribute('o:connecttype', 	'rect'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// o:lock | ||||
| 				$objWriter->startElement('o:lock'); | ||||
| 				$objWriter->writeAttribute('v:ext', 			'edit'); | ||||
| 				$objWriter->writeAttribute('aspectratio', 		't'); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Loop through images | ||||
| 			foreach ($images as $key => $value) { | ||||
| 				$this->_writeVMLHeaderFooterImage($objWriter, $key, $value); | ||||
| 			} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write VML comment to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter		$objWriter 			XML Writer | ||||
| 	 * @param	string							$pReference			Reference | ||||
| 	 * @param 	PHPExcel_Worksheet_HeaderFooterDrawing	$pImage		Image | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function _writeVMLHeaderFooterImage(PHPExcel_Shared_XMLWriter $objWriter = null, $pReference = '', PHPExcel_Worksheet_HeaderFooterDrawing $pImage = null) | ||||
| 	{ | ||||
| 		// Calculate object id | ||||
| 		preg_match('{(\d+)}', md5($pReference), $m); | ||||
| 		$id = 1500 + (substr($m[1], 0, 2) * 1); | ||||
|  | ||||
| 		// Calculate offset | ||||
| 		$width = $pImage->getWidth(); | ||||
| 		$height = $pImage->getHeight(); | ||||
| 		$marginLeft = $pImage->getOffsetX(); | ||||
| 		$marginTop = $pImage->getOffsetY(); | ||||
|  | ||||
| 		// v:shape | ||||
| 		$objWriter->startElement('v:shape'); | ||||
| 		$objWriter->writeAttribute('id', 			$pReference); | ||||
| 		$objWriter->writeAttribute('o:spid', 		'_x0000_s' . $id); | ||||
| 		$objWriter->writeAttribute('type', 			'#_x0000_t75'); | ||||
| 		$objWriter->writeAttribute('style', 		"position:absolute;margin-left:{$marginLeft}px;margin-top:{$marginTop}px;width:{$width}px;height:{$height}px;z-index:1"); | ||||
|  | ||||
| 			// v:imagedata | ||||
| 			$objWriter->startElement('v:imagedata'); | ||||
| 			$objWriter->writeAttribute('o:relid', 		'rId' . $pReference); | ||||
| 			$objWriter->writeAttribute('o:title', 		$pImage->getName()); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// o:lock | ||||
| 			$objWriter->startElement('o:lock'); | ||||
| 			$objWriter->writeAttribute('v:ext', 		'edit'); | ||||
| 			$objWriter->writeAttribute('rotation', 		't'); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of all drawings | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel							$pPHPExcel | ||||
| 	 * @return 	PHPExcel_Worksheet_Drawing[]		All drawings in PHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function allDrawings(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Get an array of all drawings | ||||
| 		$aDrawings	= array(); | ||||
|  | ||||
| 		// Loop through PHPExcel | ||||
| 		$sheetCount = $pPHPExcel->getSheetCount(); | ||||
| 		for ($i = 0; $i < $sheetCount; ++$i) { | ||||
| 			// Loop through images and add to array | ||||
| 			$iterator = $pPHPExcel->getSheet($i)->getDrawingCollection()->getIterator(); | ||||
| 			while ($iterator->valid()) { | ||||
| 				$aDrawings[] = $iterator->current(); | ||||
|  | ||||
|   				$iterator->next(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $aDrawings; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,377 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_Rels | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Write relationships to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel	$pPHPExcel | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeRelationships(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'); | ||||
|  | ||||
| 		// Relationships | ||||
| 		$objWriter->startElement('Relationships'); | ||||
| 		$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); | ||||
|  | ||||
| 			$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); | ||||
| 			if (count($customPropertyList) > 0) { | ||||
| 				// Relationship docProps/app.xml | ||||
| 				$this->_writeRelationship( | ||||
| 					$objWriter, | ||||
| 					4, | ||||
| 					'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties', | ||||
| 					'docProps/custom.xml' | ||||
| 				); | ||||
|  | ||||
| 			} | ||||
|  | ||||
| 			// Relationship docProps/app.xml | ||||
| 			$this->_writeRelationship( | ||||
| 				$objWriter, | ||||
| 				3, | ||||
| 				'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', | ||||
| 				'docProps/app.xml' | ||||
| 			); | ||||
|  | ||||
| 			// Relationship docProps/core.xml | ||||
| 			$this->_writeRelationship( | ||||
| 				$objWriter, | ||||
| 				2, | ||||
| 				'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', | ||||
| 				'docProps/core.xml' | ||||
| 			); | ||||
|  | ||||
| 			// Relationship xl/workbook.xml | ||||
| 			$this->_writeRelationship( | ||||
| 				$objWriter, | ||||
| 				1, | ||||
| 				'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', | ||||
| 				'xl/workbook.xml' | ||||
| 			); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write workbook relationships to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel	$pPHPExcel | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeWorkbookRelationships(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'); | ||||
|  | ||||
| 		// Relationships | ||||
| 		$objWriter->startElement('Relationships'); | ||||
| 		$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); | ||||
|  | ||||
| 			// Relationship styles.xml | ||||
| 			$this->_writeRelationship( | ||||
| 				$objWriter, | ||||
| 				1, | ||||
| 				'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', | ||||
| 				'styles.xml' | ||||
| 			); | ||||
|  | ||||
| 			// Relationship theme/theme1.xml | ||||
| 			$this->_writeRelationship( | ||||
| 				$objWriter, | ||||
| 				2, | ||||
| 				'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', | ||||
| 				'theme/theme1.xml' | ||||
| 			); | ||||
|  | ||||
| 			// Relationship sharedStrings.xml | ||||
| 			$this->_writeRelationship( | ||||
| 				$objWriter, | ||||
| 				3, | ||||
| 				'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', | ||||
| 				'sharedStrings.xml' | ||||
| 			); | ||||
|  | ||||
| 			// Relationships with sheets | ||||
| 			$sheetCount = $pPHPExcel->getSheetCount(); | ||||
| 			for ($i = 0; $i < $sheetCount; ++$i) { | ||||
| 				$this->_writeRelationship( | ||||
| 					$objWriter, | ||||
| 					($i + 1 + 3), | ||||
| 					'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', | ||||
| 					'worksheets/sheet' . ($i + 1) . '.xml' | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write worksheet relationships to XML format | ||||
| 	 * | ||||
| 	 * Numbering is as follows: | ||||
| 	 * 	rId1 				- Drawings | ||||
| 	 *  rId_hyperlink_x 	- Hyperlinks | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet		$pWorksheet | ||||
| 	 * @param 	int						$pWorksheetId | ||||
| 	 * @return 	string 					XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1) | ||||
| 	{ | ||||
| 		// 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'); | ||||
|  | ||||
| 			// Write drawing relationships? | ||||
| 			if ($pWorksheet->getDrawingCollection()->count() > 0) { | ||||
| 				$this->_writeRelationship( | ||||
| 					$objWriter, | ||||
| 					1, | ||||
| 					'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing', | ||||
| 					'../drawings/drawing' . $pWorksheetId . '.xml' | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 			// Write hyperlink relationships? | ||||
| 			$i = 1; | ||||
| 			foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) { | ||||
| 				if (!$hyperlink->isInternal()) { | ||||
| 					$this->_writeRelationship( | ||||
| 						$objWriter, | ||||
| 						'_hyperlink_' . $i, | ||||
| 						'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', | ||||
| 						$hyperlink->getUrl(), | ||||
| 						'External' | ||||
| 					); | ||||
|  | ||||
| 					++$i; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			// Write comments relationship? | ||||
| 			$i = 1; | ||||
| 			if (count($pWorksheet->getComments()) > 0) { | ||||
| 				$this->_writeRelationship( | ||||
| 					$objWriter, | ||||
| 					'_comments_vml' . $i, | ||||
| 					'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', | ||||
| 					'../drawings/vmlDrawing' . $pWorksheetId . '.vml' | ||||
| 				); | ||||
|  | ||||
| 				$this->_writeRelationship( | ||||
| 					$objWriter, | ||||
| 					'_comments' . $i, | ||||
| 					'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', | ||||
| 					'../comments' . $pWorksheetId . '.xml' | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 			// Write header/footer relationship? | ||||
| 			$i = 1; | ||||
| 			if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) { | ||||
| 				$this->_writeRelationship( | ||||
| 					$objWriter, | ||||
| 					'_headerfooter_vml' . $i, | ||||
| 					'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', | ||||
| 					'../drawings/vmlDrawingHF' . $pWorksheetId . '.vml' | ||||
| 				); | ||||
| 			} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write drawing relationships to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet			$pWorksheet | ||||
| 	 * @return 	string 						XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeDrawingRelationships(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 | ||||
| 			$i = 1; | ||||
| 			$iterator = $pWorksheet->getDrawingCollection()->getIterator(); | ||||
| 			while ($iterator->valid()) { | ||||
| 				if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing | ||||
| 					|| $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) { | ||||
| 					// Write relationship for image drawing | ||||
| 					$this->_writeRelationship( | ||||
| 						$objWriter, | ||||
| 						$i, | ||||
| 						'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', | ||||
| 						'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename()) | ||||
| 					); | ||||
| 				} | ||||
|  | ||||
| 				$iterator->next(); | ||||
| 				++$i; | ||||
| 			} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write header/footer drawing relationships to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet			$pWorksheet | ||||
| 	 * @return 	string 						XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	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 | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Override content type | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	int							$pId			Relationship ID. rId will be prepended! | ||||
| 	 * @param 	string						$pType			Relationship type | ||||
| 	 * @param 	string 						$pTarget		Relationship target | ||||
| 	 * @param 	string 						$pTargetMode	Relationship target mode | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeRelationship(PHPExcel_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') | ||||
| 	{ | ||||
| 		if ($pType != '' && $pTarget != '') { | ||||
| 			// Write relationship | ||||
| 			$objWriter->startElement('Relationship'); | ||||
| 			$objWriter->writeAttribute('Id', 		'rId' . $pId); | ||||
| 			$objWriter->writeAttribute('Type', 		$pType); | ||||
| 			$objWriter->writeAttribute('Target',	$pTarget); | ||||
|  | ||||
| 			if ($pTargetMode != '') { | ||||
| 				$objWriter->writeAttribute('TargetMode',	$pTargetMode); | ||||
| 			} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
| 		} else { | ||||
| 			throw new Exception("Invalid parameters passed."); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,243 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_StringTable | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Create worksheet stringtable | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Worksheet 	$pSheet				Worksheet | ||||
| 	 * @param 	string[] 				$pExistingTable 	Existing table to eventually merge with | ||||
| 	 * @return 	string[] 				String table for worksheet | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function createStringTable($pSheet = null, $pExistingTable = null) | ||||
| 	{ | ||||
| 		if (!is_null($pSheet)) { | ||||
| 			// Create string lookup table | ||||
| 			$aStringTable = array(); | ||||
| 			$cellCollection = null; | ||||
| 			$aFlippedStringTable = null;	// For faster lookup | ||||
|  | ||||
| 			// Is an existing table given? | ||||
| 			if (!is_null($pExistingTable) && is_array($pExistingTable)) { | ||||
| 				$aStringTable = $pExistingTable; | ||||
| 			} | ||||
|  | ||||
| 			// Fill index array | ||||
| 			$aFlippedStringTable = $this->flipStringTable($aStringTable); | ||||
|  | ||||
| 			// Loop through cells | ||||
| 			foreach ($pSheet->getCellCollection() as $cellID) { | ||||
| 				$cell = $pSheet->getCell($cellID); | ||||
| 				$cellValue = $cell->getValue(); | ||||
| 				if (!is_object($cellValue) && | ||||
| 					!is_null($cellValue) && | ||||
| 					$cellValue !== '' && | ||||
| 					!isset($aFlippedStringTable[$cellValue]) && | ||||
| 					($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) { | ||||
| 						$aStringTable[] = $cellValue; | ||||
| 						$aFlippedStringTable[$cellValue] = 1; | ||||
| 				} elseif ($cellValue instanceof PHPExcel_RichText && | ||||
| 						  !is_null($cellValue) && | ||||
| 						  !isset($aFlippedStringTable[$cellValue->getHashCode()])) { | ||||
| 								$aStringTable[] = $cellValue; | ||||
| 								$aFlippedStringTable[$cellValue->getHashCode()] = 1; | ||||
| 	        	} | ||||
| 	        } | ||||
|  | ||||
| 	        // Return | ||||
| 	        return $aStringTable; | ||||
| 		} else { | ||||
| 			throw new Exception("Invalid PHPExcel_Worksheet object passed."); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write string table to XML format | ||||
| 	 * | ||||
| 	 * @param 	string[] 	$pStringTable | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeStringTable($pStringTable = null) | ||||
| 	{ | ||||
| 		if (!is_null($pStringTable)) { | ||||
| 			// 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'); | ||||
|  | ||||
| 			// String table | ||||
| 			$objWriter->startElement('sst'); | ||||
| 			$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); | ||||
| 			$objWriter->writeAttribute('uniqueCount', count($pStringTable)); | ||||
|  | ||||
| 				// Loop through string table | ||||
| 				foreach ($pStringTable as $textElement) { | ||||
| 					$objWriter->startElement('si'); | ||||
|  | ||||
| 						if (! $textElement instanceof PHPExcel_RichText) { | ||||
| 							$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $textElement ); | ||||
| 							$objWriter->startElement('t'); | ||||
| 							if ($textToWrite !== trim($textToWrite)) { | ||||
| 								$objWriter->writeAttribute('xml:space', 'preserve'); | ||||
| 							} | ||||
| 							$objWriter->writeRawData($textToWrite); | ||||
| 							$objWriter->endElement(); | ||||
| 						} else if ($textElement instanceof PHPExcel_RichText) { | ||||
| 							$this->writeRichText($objWriter, $textElement); | ||||
| 						} | ||||
|  | ||||
|                     $objWriter->endElement(); | ||||
| 				} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Return | ||||
| 			return $objWriter->getData(); | ||||
| 		} else { | ||||
| 			throw new Exception("Invalid string table array passed."); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Rich Text | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter		$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_RichText				$pRichText		Rich text | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null) | ||||
| 	{ | ||||
| 		// Loop through rich text elements | ||||
| 		$elements = $pRichText->getRichTextElements(); | ||||
| 		foreach ($elements as $element) { | ||||
| 			// r | ||||
| 			$objWriter->startElement('r'); | ||||
|  | ||||
| 				// rPr | ||||
| 				if ($element instanceof PHPExcel_RichText_Run) { | ||||
| 					// rPr | ||||
| 					$objWriter->startElement('rPr'); | ||||
|  | ||||
| 						// rFont | ||||
| 						$objWriter->startElement('rFont'); | ||||
| 						$objWriter->writeAttribute('val', $element->getFont()->getName()); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// Bold | ||||
| 						$objWriter->startElement('b'); | ||||
| 						$objWriter->writeAttribute('val', ($element->getFont()->getBold() ? 'true' : 'false')); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// Italic | ||||
| 						$objWriter->startElement('i'); | ||||
| 						$objWriter->writeAttribute('val', ($element->getFont()->getItalic() ? 'true' : 'false')); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// Superscript / subscript | ||||
| 						if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) { | ||||
| 							$objWriter->startElement('vertAlign'); | ||||
| 							if ($element->getFont()->getSuperScript()) { | ||||
| 								$objWriter->writeAttribute('val', 'superscript'); | ||||
| 							} else if ($element->getFont()->getSubScript()) { | ||||
| 								$objWriter->writeAttribute('val', 'subscript'); | ||||
| 							} | ||||
| 							$objWriter->endElement(); | ||||
| 						} | ||||
|  | ||||
| 						// Strikethrough | ||||
| 						$objWriter->startElement('strike'); | ||||
| 						$objWriter->writeAttribute('val', ($element->getFont()->getStrikethrough() ? 'true' : 'false')); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// Color | ||||
| 						$objWriter->startElement('color'); | ||||
| 						$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB()); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// Size | ||||
| 						$objWriter->startElement('sz'); | ||||
| 						$objWriter->writeAttribute('val', $element->getFont()->getSize()); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 						// Underline | ||||
| 						$objWriter->startElement('u'); | ||||
| 						$objWriter->writeAttribute('val', $element->getFont()->getUnderline()); | ||||
| 						$objWriter->endElement(); | ||||
|  | ||||
| 					$objWriter->endElement(); | ||||
| 				} | ||||
|  | ||||
| 				// t | ||||
| 				$objWriter->startElement('t'); | ||||
| 				$objWriter->writeAttribute('xml:space', 'preserve'); | ||||
| 				$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() )); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Flip string table (for index searching) | ||||
| 	 * | ||||
| 	 * @param 	array	$stringTable	Stringtable | ||||
| 	 * @return 	array | ||||
| 	 */ | ||||
| 	public function flipStringTable($stringTable = array()) { | ||||
| 		// Return value | ||||
| 		$returnValue = array(); | ||||
|  | ||||
| 		// Loop through stringtable and add flipped items to $returnValue | ||||
| 		foreach ($stringTable as $key => $value) { | ||||
| 			if (! $value instanceof PHPExcel_RichText) { | ||||
| 				$returnValue[$value] = $key; | ||||
| 			} else if ($value instanceof PHPExcel_RichText) { | ||||
| 				$returnValue[$value->getHashCode()] = $key; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// Return | ||||
| 		return $returnValue; | ||||
| 	} | ||||
| } | ||||
| @ -0,0 +1,665 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_Style | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Write styles to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel	$pPHPExcel | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeStyles(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'); | ||||
|  | ||||
| 		// styleSheet | ||||
| 		$objWriter->startElement('styleSheet'); | ||||
| 		$objWriter->writeAttribute('xml:space', 'preserve'); | ||||
| 		$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); | ||||
|  | ||||
| 			// numFmts | ||||
| 			$objWriter->startElement('numFmts'); | ||||
| 			$objWriter->writeAttribute('count', $this->getParentWriter()->getNumFmtHashTable()->count()); | ||||
|  | ||||
| 				// numFmt | ||||
| 				for ($i = 0; $i < $this->getParentWriter()->getNumFmtHashTable()->count(); ++$i) { | ||||
| 					$this->_writeNumFmt($objWriter, $this->getParentWriter()->getNumFmtHashTable()->getByIndex($i), $i); | ||||
| 				} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// fonts | ||||
| 			$objWriter->startElement('fonts'); | ||||
| 			$objWriter->writeAttribute('count', $this->getParentWriter()->getFontHashTable()->count()); | ||||
|  | ||||
| 				// font | ||||
| 				for ($i = 0; $i < $this->getParentWriter()->getFontHashTable()->count(); ++$i) { | ||||
| 					$this->_writeFont($objWriter, $this->getParentWriter()->getFontHashTable()->getByIndex($i)); | ||||
| 				} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// fills | ||||
| 			$objWriter->startElement('fills'); | ||||
| 			$objWriter->writeAttribute('count', $this->getParentWriter()->getFillHashTable()->count()); | ||||
|  | ||||
| 				// fill | ||||
| 				for ($i = 0; $i < $this->getParentWriter()->getFillHashTable()->count(); ++$i) { | ||||
| 					$this->_writeFill($objWriter, $this->getParentWriter()->getFillHashTable()->getByIndex($i)); | ||||
| 				} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// borders | ||||
| 			$objWriter->startElement('borders'); | ||||
| 			$objWriter->writeAttribute('count', $this->getParentWriter()->getBordersHashTable()->count()); | ||||
|  | ||||
| 				// border | ||||
| 				for ($i = 0; $i < $this->getParentWriter()->getBordersHashTable()->count(); ++$i) { | ||||
| 					$this->_writeBorder($objWriter, $this->getParentWriter()->getBordersHashTable()->getByIndex($i)); | ||||
| 				} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// cellStyleXfs | ||||
| 			$objWriter->startElement('cellStyleXfs'); | ||||
| 			$objWriter->writeAttribute('count', 1); | ||||
|  | ||||
| 				// xf | ||||
| 				$objWriter->startElement('xf'); | ||||
| 					$objWriter->writeAttribute('numFmtId', 	0); | ||||
| 					$objWriter->writeAttribute('fontId', 	0); | ||||
| 					$objWriter->writeAttribute('fillId', 	0); | ||||
| 					$objWriter->writeAttribute('borderId',	0); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// cellXfs | ||||
| 			$objWriter->startElement('cellXfs'); | ||||
| 			$objWriter->writeAttribute('count', count($pPHPExcel->getCellXfCollection())); | ||||
|  | ||||
| 				// xf | ||||
| 				foreach ($pPHPExcel->getCellXfCollection() as $cellXf) { | ||||
| 					$this->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel); | ||||
| 				} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// cellStyles | ||||
| 			$objWriter->startElement('cellStyles'); | ||||
| 			$objWriter->writeAttribute('count', 1); | ||||
|  | ||||
| 				// cellStyle | ||||
| 				$objWriter->startElement('cellStyle'); | ||||
| 					$objWriter->writeAttribute('name', 		'Normal'); | ||||
| 					$objWriter->writeAttribute('xfId', 		0); | ||||
| 					$objWriter->writeAttribute('builtinId',	0); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// dxfs | ||||
| 			$objWriter->startElement('dxfs'); | ||||
| 			$objWriter->writeAttribute('count', $this->getParentWriter()->getStylesConditionalHashTable()->count()); | ||||
|  | ||||
| 				// dxf | ||||
| 				for ($i = 0; $i < $this->getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) { | ||||
| 					$this->_writeCellStyleDxf($objWriter, $this->getParentWriter()->getStylesConditionalHashTable()->getByIndex($i)->getStyle()); | ||||
| 				} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// tableStyles | ||||
| 			$objWriter->startElement('tableStyles'); | ||||
| 			$objWriter->writeAttribute('defaultTableStyle', 'TableStyleMedium9'); | ||||
| 			$objWriter->writeAttribute('defaultPivotStyle', 'PivotTableStyle1'); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Fill | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style_Fill			$pFill			Fill style | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null) | ||||
| 	{ | ||||
| 		// Check if this is a pattern type or gradient type | ||||
| 		if ($pFill->getFillType() == PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR | ||||
| 			|| $pFill->getFillType() == PHPExcel_Style_Fill::FILL_GRADIENT_PATH) { | ||||
| 			// Gradient fill | ||||
| 			$this->_writeGradientFill($objWriter, $pFill); | ||||
| 		} else { | ||||
| 			// Pattern fill | ||||
| 			$this->_writePatternFill($objWriter, $pFill); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Gradient Fill | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style_Fill			$pFill			Fill style | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeGradientFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null) | ||||
| 	{ | ||||
| 		// fill | ||||
| 		$objWriter->startElement('fill'); | ||||
|  | ||||
| 			// gradientFill | ||||
| 			$objWriter->startElement('gradientFill'); | ||||
| 				$objWriter->writeAttribute('type', 		$pFill->getFillType()); | ||||
| 				$objWriter->writeAttribute('degree', 	$pFill->getRotation()); | ||||
|  | ||||
| 				// stop | ||||
| 				$objWriter->startElement('stop'); | ||||
| 				$objWriter->writeAttribute('position', '0'); | ||||
|  | ||||
| 					// color | ||||
| 					$objWriter->startElement('color'); | ||||
| 					$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB()); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// stop | ||||
| 				$objWriter->startElement('stop'); | ||||
| 				$objWriter->writeAttribute('position', '1'); | ||||
|  | ||||
| 					// color | ||||
| 					$objWriter->startElement('color'); | ||||
| 					$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB()); | ||||
| 					$objWriter->endElement(); | ||||
|  | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Pattern Fill | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style_Fill					$pFill			Fill style | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writePatternFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null) | ||||
| 	{ | ||||
| 		// fill | ||||
| 		$objWriter->startElement('fill'); | ||||
|  | ||||
| 			// patternFill | ||||
| 			$objWriter->startElement('patternFill'); | ||||
| 				$objWriter->writeAttribute('patternType', $pFill->getFillType()); | ||||
|  | ||||
| 				// fgColor | ||||
| 				$objWriter->startElement('fgColor'); | ||||
| 				$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB()); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 				// bgColor | ||||
| 				$objWriter->startElement('bgColor'); | ||||
| 				$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB()); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Font | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter		$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style_Font				$pFont			Font style | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null) | ||||
| 	{ | ||||
| 		// font | ||||
| 		$objWriter->startElement('font'); | ||||
|  | ||||
| 			// Name | ||||
| 			$objWriter->startElement('name'); | ||||
| 			$objWriter->writeAttribute('val', $pFont->getName()); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Size | ||||
| 			$objWriter->startElement('sz'); | ||||
| 			$objWriter->writeAttribute('val', $pFont->getSize()); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does | ||||
| 			// for conditional formatting). Otherwise it will apparently not be picked up in conditional | ||||
| 			// formatting style dialog | ||||
| 			$objWriter->startElement('b'); | ||||
| 			$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0'); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Italic | ||||
| 			$objWriter->startElement('i'); | ||||
| 			$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0'); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Superscript / subscript | ||||
| 			if ($pFont->getSuperScript() || $pFont->getSubScript()) { | ||||
| 				$objWriter->startElement('vertAlign'); | ||||
| 				if ($pFont->getSuperScript()) { | ||||
| 					$objWriter->writeAttribute('val', 'superscript'); | ||||
| 				} else if ($pFont->getSubScript()) { | ||||
| 					$objWriter->writeAttribute('val', 'subscript'); | ||||
| 				} | ||||
| 				$objWriter->endElement(); | ||||
| 			} | ||||
|  | ||||
| 			// Underline | ||||
| 			$objWriter->startElement('u'); | ||||
| 			$objWriter->writeAttribute('val', $pFont->getUnderline()); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Strikethrough | ||||
| 			$objWriter->startElement('strike'); | ||||
| 			$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0'); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 			// Foreground color | ||||
| 			$objWriter->startElement('color'); | ||||
| 			$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB()); | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Border | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style_Borders				$pBorders		Borders style | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeBorder(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Borders $pBorders = null) | ||||
| 	{ | ||||
| 		// Write border | ||||
| 		$objWriter->startElement('border'); | ||||
| 			// Diagonal? | ||||
| 			switch ($pBorders->getDiagonalDirection()) { | ||||
| 				case PHPExcel_Style_Borders::DIAGONAL_UP: | ||||
| 					$objWriter->writeAttribute('diagonalUp', 	'true'); | ||||
| 					$objWriter->writeAttribute('diagonalDown', 	'false'); | ||||
| 					break; | ||||
| 				case PHPExcel_Style_Borders::DIAGONAL_DOWN: | ||||
| 					$objWriter->writeAttribute('diagonalUp', 	'false'); | ||||
| 					$objWriter->writeAttribute('diagonalDown', 	'true'); | ||||
| 					break; | ||||
| 				case PHPExcel_Style_Borders::DIAGONAL_BOTH: | ||||
| 					$objWriter->writeAttribute('diagonalUp', 	'true'); | ||||
| 					$objWriter->writeAttribute('diagonalDown', 	'true'); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			// BorderPr | ||||
| 			$this->_writeBorderPr($objWriter, 'left', 			$pBorders->getLeft()); | ||||
| 			$this->_writeBorderPr($objWriter, 'right', 			$pBorders->getRight()); | ||||
| 			$this->_writeBorderPr($objWriter, 'top', 			$pBorders->getTop()); | ||||
| 			$this->_writeBorderPr($objWriter, 'bottom', 		$pBorders->getBottom()); | ||||
| 			$this->_writeBorderPr($objWriter, 'diagonal', 		$pBorders->getDiagonal()); | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Cell Style Xf | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style						$pStyle			Style | ||||
| 	 * @param 	PHPExcel							$pPHPExcel		Workbook | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	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->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()); | ||||
| 				} | ||||
| 			$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(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Cell Style Dxf | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 		$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style					$pStyle			Style | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	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'); | ||||
| 				$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->endElement(); | ||||
|  | ||||
| 			// border | ||||
| 			$this->_writeBorder($objWriter, $pStyle->getBorders()); | ||||
|  | ||||
| 			// 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(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write BorderPr | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter		$objWriter 		XML Writer | ||||
| 	 * @param 	string							$pName			Element name | ||||
| 	 * @param 	PHPExcel_Style_Border			$pBorder		Border style | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeBorderPr(PHPExcel_Shared_XMLWriter $objWriter = null, $pName = 'left', PHPExcel_Style_Border $pBorder = null) | ||||
| 	{ | ||||
| 		// Write BorderPr | ||||
| 		if ($pBorder->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) { | ||||
| 			$objWriter->startElement($pName); | ||||
| 			$objWriter->writeAttribute('style', 	$pBorder->getBorderStyle()); | ||||
|  | ||||
| 				// color | ||||
| 				$objWriter->startElement('color'); | ||||
| 				$objWriter->writeAttribute('rgb', 	$pBorder->getColor()->getARGB()); | ||||
| 				$objWriter->endElement(); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write NumberFormat | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter			$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Style_NumberFormat			$pNumberFormat	Number Format | ||||
| 	 * @param 	int									$pId			Number Format identifier | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeNumFmt(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_NumberFormat $pNumberFormat = null, $pId = 0) | ||||
| 	{ | ||||
| 		// Translate formatcode | ||||
| 		$formatCode = $pNumberFormat->getFormatCode(); | ||||
|  | ||||
| 		// numFmt | ||||
| 		$objWriter->startElement('numFmt'); | ||||
| 			$objWriter->writeAttribute('numFmtId', 		($pId + 164)); | ||||
| 			$objWriter->writeAttribute('formatCode', 	$formatCode); | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of all styles | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel				$pPHPExcel | ||||
| 	 * @return 	PHPExcel_Style[]		All styles in PHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function allStyles(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		$aStyles = $pPHPExcel->getCellXfCollection(); | ||||
|  | ||||
| 		return $aStyles; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of all conditional styles | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel							$pPHPExcel | ||||
| 	 * @return 	PHPExcel_Style_Conditional[]		All conditional styles in PHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function allConditionalStyles(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Get an array of all styles | ||||
| 		$aStyles		= array(); | ||||
|  | ||||
| 		$sheetCount = $pPHPExcel->getSheetCount(); | ||||
| 		for ($i = 0; $i < $sheetCount; ++$i) { | ||||
| 			foreach ($pPHPExcel->getSheet($i)->getConditionalStylesCollection() as $conditionalStyles) { | ||||
| 				foreach ($conditionalStyles as $conditionalStyle) { | ||||
| 					$aStyles[] = $conditionalStyle; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $aStyles; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of all fills | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel						$pPHPExcel | ||||
| 	 * @return 	PHPExcel_Style_Fill[]		All fills in PHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function allFills(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Get an array of unique fills | ||||
| 		$aFills 	= array(); | ||||
|  | ||||
| 		// Two first fills are predefined | ||||
| 		$fill0 = new PHPExcel_Style_Fill(); | ||||
| 		$fill0->setFillType(PHPExcel_Style_Fill::FILL_NONE); | ||||
| 		$aFills[] = $fill0; | ||||
|  | ||||
| 		$fill1 = new PHPExcel_Style_Fill(); | ||||
| 		$fill1->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_GRAY125); | ||||
| 		$aFills[] = $fill1; | ||||
|  | ||||
| 		// The remaining fills | ||||
| 		$aStyles 	= $this->allStyles($pPHPExcel); | ||||
| 		foreach ($aStyles as $style) { | ||||
| 			if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) { | ||||
| 				$aFills[ $style->getFill()->getHashCode() ] = $style->getFill(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $aFills; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of all fonts | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel						$pPHPExcel | ||||
| 	 * @return 	PHPExcel_Style_Font[]		All fonts in PHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function allFonts(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Get an array of unique fonts | ||||
| 		$aFonts 	= array(); | ||||
| 		$aStyles 	= $this->allStyles($pPHPExcel); | ||||
|  | ||||
| 		foreach ($aStyles as $style) { | ||||
| 			if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) { | ||||
| 				$aFonts[ $style->getFont()->getHashCode() ] = $style->getFont(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $aFonts; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of all borders | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel						$pPHPExcel | ||||
| 	 * @return 	PHPExcel_Style_Borders[]		All borders in PHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function allBorders(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Get an array of unique borders | ||||
| 		$aBorders 	= array(); | ||||
| 		$aStyles 	= $this->allStyles($pPHPExcel); | ||||
|  | ||||
| 		foreach ($aStyles as $style) { | ||||
| 			if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) { | ||||
| 				$aBorders[ $style->getBorders()->getHashCode() ] = $style->getBorders(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $aBorders; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get an array of all number formats | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel								$pPHPExcel | ||||
| 	 * @return 	PHPExcel_Style_NumberFormat[]		All number formats in PHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function allNumberFormats(PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Get an array of unique number formats | ||||
| 		$aNumFmts 	= array(); | ||||
| 		$aStyles 	= $this->allStyles($pPHPExcel); | ||||
|  | ||||
| 		foreach ($aStyles as $style) { | ||||
| 			if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) { | ||||
| 				$aNumFmts[ $style->getNumberFormat()->getHashCode() ] = $style->getNumberFormat(); | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $aNumFmts; | ||||
| 	} | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -0,0 +1,443 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_Workbook | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Write workbook to XML format | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel	$pPHPExcel | ||||
| 	 * @return 	string 		XML Output | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	public function writeWorkbook(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'); | ||||
|  | ||||
| 		// 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); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
|  | ||||
| 		// Return | ||||
| 		return $objWriter->getData(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write file version | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter $objWriter 		XML Writer | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeFileVersion(PHPExcel_Shared_XMLWriter $objWriter = null) | ||||
| 	{ | ||||
| 		$objWriter->startElement('fileVersion'); | ||||
| 		$objWriter->writeAttribute('appName', 'xl'); | ||||
| 		$objWriter->writeAttribute('lastEdited', '4'); | ||||
| 		$objWriter->writeAttribute('lowestEdited', '4'); | ||||
| 		$objWriter->writeAttribute('rupBuild', '4505'); | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write WorkbookPr | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter $objWriter 		XML Writer | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	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(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write BookViews | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel					$pPHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeBookViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// bookViews | ||||
| 		$objWriter->startElement('bookViews'); | ||||
|  | ||||
| 			// workbookView | ||||
| 			$objWriter->startElement('workbookView'); | ||||
|  | ||||
| 			$objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex()); | ||||
| 			$objWriter->writeAttribute('autoFilterDateGrouping', '1'); | ||||
| 			$objWriter->writeAttribute('firstSheet', '0'); | ||||
| 			$objWriter->writeAttribute('minimized', '0'); | ||||
| 			$objWriter->writeAttribute('showHorizontalScroll', '1'); | ||||
| 			$objWriter->writeAttribute('showSheetTabs', '1'); | ||||
| 			$objWriter->writeAttribute('showVerticalScroll', '1'); | ||||
| 			$objWriter->writeAttribute('tabRatio', '600'); | ||||
| 			$objWriter->writeAttribute('visibility', 'visible'); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write WorkbookProtection | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel					$pPHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeWorkbookProtection(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		if ($pPHPExcel->getSecurity()->isSecurityEnabled()) { | ||||
| 			$objWriter->startElement('workbookProtection'); | ||||
| 			$objWriter->writeAttribute('lockRevision',		($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false')); | ||||
| 			$objWriter->writeAttribute('lockStructure', 	($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false')); | ||||
| 			$objWriter->writeAttribute('lockWindows', 		($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false')); | ||||
|  | ||||
| 			if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') { | ||||
| 				$objWriter->writeAttribute('revisionsPassword',	$pPHPExcel->getSecurity()->getRevisionsPassword()); | ||||
| 			} | ||||
|  | ||||
| 			if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') { | ||||
| 				$objWriter->writeAttribute('workbookPassword',	$pPHPExcel->getSecurity()->getWorkbookPassword()); | ||||
| 			} | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write calcPr | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter $objWriter 		XML Writer | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null) | ||||
| 	{ | ||||
| 		$objWriter->startElement('calcPr'); | ||||
|  | ||||
| 		$objWriter->writeAttribute('calcId', 			'124519'); | ||||
| 		$objWriter->writeAttribute('calcMode', 			'auto'); | ||||
| 		$objWriter->writeAttribute('fullCalcOnLoad', 	'1'); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write sheets | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel					$pPHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Write sheets | ||||
| 		$objWriter->startElement('sheets'); | ||||
| 		$sheetCount = $pPHPExcel->getSheetCount(); | ||||
| 		for ($i = 0; $i < $sheetCount; ++$i) { | ||||
| 			// sheet | ||||
| 			$this->_writeSheet( | ||||
| 				$objWriter, | ||||
| 				$pPHPExcel->getSheet($i)->getTitle(), | ||||
| 				($i + 1), | ||||
| 				($i + 1 + 3), | ||||
| 				$pPHPExcel->getSheet($i)->getSheetState() | ||||
| 			); | ||||
| 		} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write sheet | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter 	$objWriter 		XML Writer | ||||
| 	 * @param 	string 						$pSheetname 		Sheet name | ||||
| 	 * @param 	int							$pSheetId	 		Sheet id | ||||
| 	 * @param 	int							$pRelId				Relationship ID | ||||
| 	 * @param   string                      $sheetState         Sheet state (visible, hidden, veryHidden) | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeSheet(PHPExcel_Shared_XMLWriter $objWriter = null, $pSheetname = '', $pSheetId = 1, $pRelId = 1, $sheetState = 'visible') | ||||
| 	{ | ||||
| 		if ($pSheetname != '') { | ||||
| 			// Write sheet | ||||
| 			$objWriter->startElement('sheet'); | ||||
| 			$objWriter->writeAttribute('name', 		$pSheetname); | ||||
| 			$objWriter->writeAttribute('sheetId', 	$pSheetId); | ||||
| 			if ($sheetState != 'visible' && $sheetState != '') { | ||||
| 				$objWriter->writeAttribute('state', $sheetState); | ||||
| 			} | ||||
| 			$objWriter->writeAttribute('r:id', 		'rId' . $pRelId); | ||||
| 			$objWriter->endElement(); | ||||
| 		} else { | ||||
| 			throw new Exception("Invalid parameters passed."); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Defined Names | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel					$pPHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeDefinedNames(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null) | ||||
| 	{ | ||||
| 		// Write defined names | ||||
| 		$objWriter->startElement('definedNames'); | ||||
|  | ||||
| 		// Named ranges | ||||
| 		if (count($pPHPExcel->getNamedRanges()) > 0) { | ||||
| 			// Named ranges | ||||
| 			$this->_writeNamedRanges($objWriter, $pPHPExcel); | ||||
| 		} | ||||
|  | ||||
| 		// Other defined names | ||||
| 		$sheetCount = $pPHPExcel->getSheetCount(); | ||||
| 		for ($i = 0; $i < $sheetCount; ++$i) { | ||||
| 			// definedName for autoFilter | ||||
| 			$this->_writeDefinedNameForAutofilter($objWriter, $pPHPExcel->getSheet($i), $i); | ||||
|  | ||||
| 			// definedName for Print_Titles | ||||
| 			$this->_writeDefinedNameForPrintTitles($objWriter, $pPHPExcel->getSheet($i), $i); | ||||
|  | ||||
| 			// definedName for Print_Area | ||||
| 			$this->_writeDefinedNameForPrintArea($objWriter, $pPHPExcel->getSheet($i), $i); | ||||
| 		} | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write named ranges | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel					$pPHPExcel | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeNamedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel) | ||||
| 	{ | ||||
| 		// Loop named ranges | ||||
| 		$namedRanges = $pPHPExcel->getNamedRanges(); | ||||
| 		foreach ($namedRanges as $namedRange) { | ||||
| 			$this->_writeDefinedNameForNamedRange($objWriter, $namedRange); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Defined Name for autoFilter | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_NamedRange			$pNamedRange | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeDefinedNameForNamedRange(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_NamedRange $pNamedRange) | ||||
| 	{ | ||||
| 		// definedName for named range | ||||
| 		$objWriter->startElement('definedName'); | ||||
| 		$objWriter->writeAttribute('name',			$pNamedRange->getName()); | ||||
| 		if ($pNamedRange->getLocalOnly()) { | ||||
| 			$objWriter->writeAttribute('localSheetId',	$pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope())); | ||||
| 		} | ||||
|  | ||||
| 		// Create absolute coordinate and write as raw text | ||||
| 		$range = PHPExcel_Cell::splitRange($pNamedRange->getRange()); | ||||
| 		for ($i = 0; $i < count($range); $i++) { | ||||
| 			$range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteReference($range[$i][0]); | ||||
| 			if (isset($range[$i][1])) { | ||||
| 				$range[$i][1] = PHPExcel_Cell::absoluteReference($range[$i][1]); | ||||
| 			} | ||||
| 		} | ||||
| 		$range = PHPExcel_Cell::buildRange($range); | ||||
|  | ||||
| 		$objWriter->writeRawData($range); | ||||
|  | ||||
| 		$objWriter->endElement(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Defined Name for autoFilter | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Worksheet			$pSheet | ||||
| 	 * @param 	int							$pSheetId | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeDefinedNameForAutofilter(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0) | ||||
| 	{ | ||||
| 		// definedName for autoFilter | ||||
| 		if ($pSheet->getAutoFilter() != '') { | ||||
| 			$objWriter->startElement('definedName'); | ||||
| 			$objWriter->writeAttribute('name',			'_xlnm._FilterDatabase'); | ||||
| 			$objWriter->writeAttribute('localSheetId',	$pSheetId); | ||||
| 			$objWriter->writeAttribute('hidden',		'1'); | ||||
|  | ||||
| 			// Create absolute coordinate and write as raw text | ||||
| 			$range = PHPExcel_Cell::splitRange($pSheet->getAutoFilter()); | ||||
| 			$range = $range[0]; | ||||
| 			$range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]); | ||||
| 			$range[1] = PHPExcel_Cell::absoluteCoordinate($range[1]); | ||||
| 			$range = implode(':', $range); | ||||
|  | ||||
| 			$objWriter->writeRawData('\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . $range); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Defined Name for PrintTitles | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Worksheet			$pSheet | ||||
| 	 * @param 	int							$pSheetId | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	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(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Write Defined Name for PrintTitles | ||||
| 	 * | ||||
| 	 * @param 	PHPExcel_Shared_XMLWriter	$objWriter 		XML Writer | ||||
| 	 * @param 	PHPExcel_Worksheet			$pSheet | ||||
| 	 * @param 	int							$pSheetId | ||||
| 	 * @throws 	Exception | ||||
| 	 */ | ||||
| 	private function _writeDefinedNameForPrintArea(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0) | ||||
| 	{ | ||||
| 		// definedName for PrintArea | ||||
| 		if ($pSheet->getPageSetup()->isPrintAreaSet()) { | ||||
| 			$objWriter->startElement('definedName'); | ||||
| 			$objWriter->writeAttribute('name',			'_xlnm.Print_Area'); | ||||
| 			$objWriter->writeAttribute('localSheetId',	$pSheetId); | ||||
|  | ||||
| 			// Setting string | ||||
| 			$settingString = ''; | ||||
|  | ||||
| 			// Print area | ||||
| 			$printArea = PHPExcel_Cell::splitRange($pSheet->getPageSetup()->getPrintArea()); | ||||
|  | ||||
| 			$chunks = array(); | ||||
| 			foreach ($printArea as $printAreaRect) { | ||||
| 				$printAreaRect[0] = PHPExcel_Cell::absoluteReference($printAreaRect[0]); | ||||
| 				$printAreaRect[1] = PHPExcel_Cell::absoluteReference($printAreaRect[1]); | ||||
| 				$chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect); | ||||
| 			} | ||||
|  | ||||
| 			$objWriter->writeRawData(implode(',', $chunks)); | ||||
|  | ||||
| 			$objWriter->endElement(); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -0,0 +1,81 @@ | ||||
| <?php | ||||
| /** | ||||
|  * PHPExcel | ||||
|  * | ||||
|  * Copyright (c) 2006 - 2011 PHPExcel | ||||
|  * | ||||
|  * This library is free software; you can redistribute it and/or | ||||
|  * modify it under the terms of the GNU Lesser General Public | ||||
|  * License as published by the Free Software Foundation; either | ||||
|  * version 2.1 of the License, or (at your option) any later version. | ||||
|  * | ||||
|  * This library is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | ||||
|  * Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public | ||||
|  * License along with this library; if not, write to the Free Software | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | ||||
|  * @version    1.7.6, 2011-02-27 | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * PHPExcel_Writer_Excel2007_WriterPart | ||||
|  * | ||||
|  * @category   PHPExcel | ||||
|  * @package    PHPExcel_Writer_Excel2007 | ||||
|  * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) | ||||
|  */ | ||||
| abstract class PHPExcel_Writer_Excel2007_WriterPart | ||||
| { | ||||
| 	/** | ||||
| 	 * Parent IWriter object | ||||
| 	 * | ||||
| 	 * @var PHPExcel_Writer_IWriter | ||||
| 	 */ | ||||
| 	private $_parentWriter; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set parent IWriter object | ||||
| 	 * | ||||
| 	 * @param PHPExcel_Writer_IWriter	$pWriter | ||||
| 	 * @throws Exception | ||||
| 	 */ | ||||
| 	public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) { | ||||
| 		$this->_parentWriter = $pWriter; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get parent IWriter object | ||||
| 	 * | ||||
| 	 * @return PHPExcel_Writer_IWriter | ||||
| 	 * @throws Exception | ||||
| 	 */ | ||||
| 	public function getParentWriter() { | ||||
| 		if (!is_null($this->_parentWriter)) { | ||||
| 			return $this->_parentWriter; | ||||
| 		} else { | ||||
| 			throw new Exception("No parent PHPExcel_Writer_IWriter assigned."); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Set parent IWriter object | ||||
| 	 * | ||||
| 	 * @param PHPExcel_Writer_IWriter	$pWriter | ||||
| 	 * @throws Exception | ||||
| 	 */ | ||||
| 	public function __construct(PHPExcel_Writer_IWriter $pWriter = null) { | ||||
| 		if (!is_null($pWriter)) { | ||||
| 			$this->_parentWriter = $pWriter; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user