| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * PHPExcel | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-05-14 11:20:28 +00:00
										 |  |  |  * Copyright (c) 2006 - 2013 PHPExcel | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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_Reader | 
					
						
							| 
									
										
										
										
											2013-05-14 11:20:28 +00:00
										 |  |  |  * @copyright  Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL | 
					
						
							|  |  |  |  * @version    ##VERSION##, ##DATE##
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** PHPExcel root directory */ | 
					
						
							|  |  |  | if (!defined('PHPEXCEL_ROOT')) { | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @ignore | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); | 
					
						
							|  |  |  | 	require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * PHPExcel_Reader_CSV | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category   PHPExcel | 
					
						
							|  |  |  |  * @package    PHPExcel_Reader | 
					
						
							| 
									
										
										
										
											2013-05-14 11:20:28 +00:00
										 |  |  |  * @copyright  Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel) | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-11-05 21:23:38 +00:00
										 |  |  | class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Input encoding | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @access	private | 
					
						
							|  |  |  | 	 * @var	string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 	private $_inputEncoding	= 'UTF-8'; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Delimiter | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @access	private | 
					
						
							|  |  |  | 	 * @var string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 	private $_delimiter		= ','; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Enclosure | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @access	private | 
					
						
							|  |  |  | 	 * @var	string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 	private $_enclosure		= '"'; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Line ending | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @access	private | 
					
						
							|  |  |  | 	 * @var	string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 	private $_lineEnding	= PHP_EOL; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Sheet index to read | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @access	private | 
					
						
							|  |  |  | 	 * @var	int | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 	private $_sheetIndex	= 0; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Load rows contiguously | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @access	private | 
					
						
							|  |  |  | 	 * @var	int | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 	private $_contiguous	= false; | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Row counter for loading rows contiguously | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @var	int | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 	private $_contiguousRow	= -1; | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Create a new PHPExcel_Reader_CSV | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function __construct() { | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 		$this->_readFilter		= new PHPExcel_Reader_DefaultReadFilter(); | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	 * Validate that the current file is a CSV file | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @return boolean | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	protected function _isValidFormat() | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 		return TRUE; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Set input encoding | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @param string $pValue Input encoding | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function setInputEncoding($pValue = 'UTF-8') | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		$this->_inputEncoding = $pValue; | 
					
						
							|  |  |  | 		return $this; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Get input encoding | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @return string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function getInputEncoding() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		return $this->_inputEncoding; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	 * Move filepointer past any BOM marker | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 	 * | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	protected function _skipBOM() | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-06-03 12:39:58 +00:00
										 |  |  | 		rewind($this->_fileHandle); | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		switch ($this->_inputEncoding) { | 
					
						
							|  |  |  | 			case 'UTF-8': | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 				fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ? | 
					
						
							| 
									
										
										
										
											2013-06-03 12:39:58 +00:00
										 |  |  | 					fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0); | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			case 'UTF-16LE': | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 				fgets($this->_fileHandle, 3) == "\xFF\xFE" ? | 
					
						
							| 
									
										
										
										
											2013-06-03 12:39:58 +00:00
										 |  |  | 					fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0); | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			case 'UTF-16BE': | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 				fgets($this->_fileHandle, 3) == "\xFE\xFF" ? | 
					
						
							| 
									
										
										
										
											2013-06-03 12:39:58 +00:00
										 |  |  | 					fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0); | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			case 'UTF-32LE': | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 				fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ? | 
					
						
							| 
									
										
										
										
											2013-06-03 12:39:58 +00:00
										 |  |  | 					fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0); | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			case 'UTF-32BE': | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 				fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ? | 
					
						
							| 
									
										
										
										
											2013-06-03 12:39:58 +00:00
										 |  |  | 					fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0); | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			default: | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns) | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param 	string 		$pFilename | 
					
						
							|  |  |  | 	 * @throws	PHPExcel_Reader_Exception | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	public function listWorksheetInfo($pFilename) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Open file
 | 
					
						
							|  |  |  | 		$this->_openFile($pFilename); | 
					
						
							|  |  |  | 		if (!$this->_isValidFormat()) { | 
					
						
							|  |  |  | 			fclose ($this->_fileHandle); | 
					
						
							|  |  |  | 			throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		$fileHandle = $this->_fileHandle; | 
					
						
							| 
									
										
										
										
											2013-06-03 12:39:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 		// Skip BOM, if any
 | 
					
						
							|  |  |  | 		$this->_skipBOM(); | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$worksheetInfo = array(); | 
					
						
							|  |  |  | 		$worksheetInfo[0]['worksheetName'] = 'Worksheet'; | 
					
						
							|  |  |  | 		$worksheetInfo[0]['lastColumnLetter'] = 'A'; | 
					
						
							|  |  |  | 		$worksheetInfo[0]['lastColumnIndex'] = 0; | 
					
						
							|  |  |  | 		$worksheetInfo[0]['totalRows'] = 0; | 
					
						
							|  |  |  | 		$worksheetInfo[0]['totalColumns'] = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Loop through each line of the file in turn
 | 
					
						
							|  |  |  | 		while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { | 
					
						
							|  |  |  | 			$worksheetInfo[0]['totalRows']++; | 
					
						
							|  |  |  | 			$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']); | 
					
						
							|  |  |  | 		$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Close file
 | 
					
						
							|  |  |  | 		fclose($fileHandle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return $worksheetInfo; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Loads PHPExcel from file | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param 	string 		$pFilename | 
					
						
							|  |  |  | 	 * @return PHPExcel | 
					
						
							| 
									
										
										
										
											2012-10-29 23:48:29 +00:00
										 |  |  | 	 * @throws PHPExcel_Reader_Exception | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function load($pFilename) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Create new PHPExcel
 | 
					
						
							|  |  |  | 		$objPHPExcel = new PHPExcel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Load into this instance
 | 
					
						
							|  |  |  | 		return $this->loadIntoExisting($pFilename, $objPHPExcel); | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Loads PHPExcel from file into PHPExcel instance | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @param 	string 		$pFilename | 
					
						
							|  |  |  | 	 * @param	PHPExcel	$objPHPExcel | 
					
						
							|  |  |  | 	 * @return 	PHPExcel | 
					
						
							| 
									
										
										
										
											2012-10-29 23:48:29 +00:00
										 |  |  | 	 * @throws 	PHPExcel_Reader_Exception | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-11-25 12:16:01 +00:00
										 |  |  | 		$lineEnding = ini_get('auto_detect_line_endings'); | 
					
						
							| 
									
										
										
										
											2011-08-05 14:37:30 +00:00
										 |  |  | 		ini_set('auto_detect_line_endings', true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 		// Open file
 | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 		$this->_openFile($pFilename); | 
					
						
							|  |  |  | 		if (!$this->_isValidFormat()) { | 
					
						
							|  |  |  | 			fclose ($this->_fileHandle); | 
					
						
							|  |  |  | 			throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 		$fileHandle = $this->_fileHandle; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Skip BOM, if any
 | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 		$this->_skipBOM(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Create new PHPExcel object
 | 
					
						
							|  |  |  | 		while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { | 
					
						
							|  |  |  | 			$objPHPExcel->createSheet(); | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 		$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex); | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-03 17:48:10 +00:00
										 |  |  | 		$escapeEnclosures = array( "\\" . $this->_enclosure, | 
					
						
							|  |  |  | 								   $this->_enclosure . $this->_enclosure | 
					
						
							|  |  |  | 								 ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 		// Set our starting row based on whether we're in contiguous mode or not
 | 
					
						
							|  |  |  | 		$currentRow = 1; | 
					
						
							|  |  |  | 		if ($this->_contiguous) { | 
					
						
							| 
									
										
										
										
											2011-12-30 01:08:05 +00:00
										 |  |  | 			$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow; | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Loop through each line of the file in turn
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 		while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { | 
					
						
							| 
									
										
										
										
											2010-12-03 17:48:10 +00:00
										 |  |  | 			$columnLetter = 'A'; | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 			foreach($rowData as $rowDatum) { | 
					
						
							|  |  |  | 				if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) { | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 					// Unescape enclosures
 | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 					$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum); | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					// Convert encoding if necessary
 | 
					
						
							|  |  |  | 					if ($this->_inputEncoding !== 'UTF-8') { | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 						$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding); | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 					// Set cell value
 | 
					
						
							| 
									
										
										
										
											2011-12-30 01:08:05 +00:00
										 |  |  | 					$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum); | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2010-12-03 17:48:10 +00:00
										 |  |  | 				++$columnLetter; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 			++$currentRow; | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Close file
 | 
					
						
							|  |  |  | 		fclose($fileHandle); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-09 12:07:50 +00:00
										 |  |  | 		if ($this->_contiguous) { | 
					
						
							|  |  |  | 			$this->_contiguousRow = $currentRow; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-05 14:37:30 +00:00
										 |  |  | 		ini_set('auto_detect_line_endings', $lineEnding); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 		// Return
 | 
					
						
							|  |  |  | 		return $objPHPExcel; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Get delimiter | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @return string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function getDelimiter() { | 
					
						
							|  |  |  | 		return $this->_delimiter; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Set delimiter | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @param	string	$pValue		Delimiter, defaults to , | 
					
						
							|  |  |  | 	 * @return	PHPExcel_Reader_CSV | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function setDelimiter($pValue = ',') { | 
					
						
							|  |  |  | 		$this->_delimiter = $pValue; | 
					
						
							|  |  |  | 		return $this; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Get enclosure | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @return string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function getEnclosure() { | 
					
						
							|  |  |  | 		return $this->_enclosure; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Set enclosure | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @param	string	$pValue		Enclosure, defaults to "
 | 
					
						
							|  |  |  | 	 * @return PHPExcel_Reader_CSV | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function setEnclosure($pValue = '"') { | 
					
						
							|  |  |  | 		if ($pValue == '') { | 
					
						
							|  |  |  | 			$pValue = '"'; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		$this->_enclosure = $pValue; | 
					
						
							|  |  |  | 		return $this; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Get line ending | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @return string | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function getLineEnding() { | 
					
						
							|  |  |  | 		return $this->_lineEnding; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Set line ending | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @param	string	$pValue		Line ending, defaults to OS line ending (PHP_EOL) | 
					
						
							|  |  |  | 	 * @return PHPExcel_Reader_CSV | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function setLineEnding($pValue = PHP_EOL) { | 
					
						
							|  |  |  | 		$this->_lineEnding = $pValue; | 
					
						
							|  |  |  | 		return $this; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Get sheet index | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	 * @return integer | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function getSheetIndex() { | 
					
						
							|  |  |  | 		return $this->_sheetIndex; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Set sheet index | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2013-04-27 17:07:12 +00:00
										 |  |  | 	 * @param	integer		$pValue		Sheet index | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @return PHPExcel_Reader_CSV | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function setSheetIndex($pValue = 0) { | 
					
						
							|  |  |  | 		$this->_sheetIndex = $pValue; | 
					
						
							|  |  |  | 		return $this; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Set Contiguous | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2013-04-27 17:07:12 +00:00
										 |  |  | 	 * @param boolean $contiguous | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2013-04-27 17:07:12 +00:00
										 |  |  | 	public function setContiguous($contiguous = FALSE) | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-04-27 17:07:12 +00:00
										 |  |  | 		$this->_contiguous = (bool) $contiguous; | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 		if (!$contiguous) { | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 			$this->_contiguousRow = -1; | 
					
						
							| 
									
										
										
										
											2010-12-03 23:07:13 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 		return $this; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-31 19:17:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	/** | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * Get Contiguous | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	 * | 
					
						
							| 
									
										
										
										
											2012-03-11 17:58:38 +00:00
										 |  |  | 	 * @return boolean | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 	 */ | 
					
						
							|  |  |  | 	public function getContiguous() { | 
					
						
							|  |  |  | 		return $this->_contiguous; | 
					
						
							| 
									
										
										
										
											2013-05-06 22:39:49 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2010-10-23 22:25:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-26 19:14:53 +00:00
										 |  |  | } |