Loads PHPExcel from file

@param 	string 		$pFilename
@return 	PHPExcel
@throws 	PHPExcel_Reader_Exception
762
public function load($pFilename)
	{
		// Read the OLE file
		$this->_loadOLE($pFilename);

		// Initialisations
		$this->_phpExcel = new PHPExcel;
		$this->_phpExcel->removeSheetByIndex(0); // remove 1st sheet
		if (!$this->_readDataOnly) {
			$this->_phpExcel->removeCellStyleXfByIndex(0); // remove the default style
			$this->_phpExcel->removeCellXfByIndex(0); // remove the default style
		}

		// Read the summary information stream (containing meta data)
		$this->_readSummaryInformation();

		// Read the Additional document summary information stream (containing application-specific meta data)
		$this->_readDocumentSummaryInformation();

		// total byte size of Excel data (workbook global substream + sheet substreams)
		$this->_dataSize = strlen($this->_data);

		// initialize
		$this->_pos					= 0;
		$this->_codepage			= 'CP1252';
		$this->_formats				= array();
		$this->_objFonts			= array();
		$this->_palette				= array();
		$this->_sheets				= array();
		$this->_externalBooks		= array();
		$this->_ref					= array();
		$this->_definedname			= array();
		$this->_sst					= array();
		$this->_drawingGroupData	= '';
		$this->_xfIndex				= '';
		$this->_mapCellXfIndex		= array();
		$this->_mapCellStyleXfIndex	= array();

		// Parse Workbook Global Substream
		while ($this->_pos < $this->_dataSize) {
			$code = self::_GetInt2d($this->_data, $this->_pos);

			switch ($code) {
				case self::XLS_Type_BOF:			$this->_readBof();				break;
				case self::XLS_Type_FILEPASS:		$this->_readFilepass();			break;
				case self::XLS_Type_CODEPAGE:		$this->_readCodepage();			break;
				case self::XLS_Type_DATEMODE:		$this->_readDateMode();			break;
				case self::XLS_Type_FONT:			$this->_readFont();				break;
				case self::XLS_Type_FORMAT:			$this->_readFormat();			break;
				case self::XLS_Type_XF:				$this->_readXf();				break;
				case self::XLS_Type_XFEXT:			$this->_readXfExt();			break;
				case self::XLS_Type_STYLE:			$this->_readStyle();			break;
				case self::XLS_Type_PALETTE:		$this->_readPalette();			break;
				case self::XLS_Type_SHEET:			$this->_readSheet();			break;
				case self::XLS_Type_EXTERNALBOOK:	$this->_readExternalBook();		break;
				case self::XLS_Type_EXTERNNAME:		$this->_readExternName();		break;
				case self::XLS_Type_EXTERNSHEET:	$this->_readExternSheet();		break;
				case self::XLS_Type_DEFINEDNAME:	$this->_readDefinedName();		break;
				case self::XLS_Type_MSODRAWINGGROUP:	$this->_readMsoDrawingGroup();	break;
				case self::XLS_Type_SST:			$this->_readSst();				break;
				case self::XLS_Type_EOF:			$this->_readDefault();			break 2;
				default:							$this->_readDefault();			break;
			}
		}

		// Resolve indexed colors for font, fill, and border colors
		// Cannot be resolved already in XF record, because PALETTE record comes afterwards
		if (!$this->_readDataOnly) {
			foreach ($this->_objFonts as $objFont) {
				if (isset($objFont->colorIndex)) {
					$color = self::_readColor($objFont->colorIndex,$this->_palette,$this->_version);
					$objFont->getColor()->setRGB($color['rgb']);
				}
			}

			foreach ($this->_phpExcel->getCellXfCollection() as $objStyle) {
				// fill start and end color
				$fill = $objStyle->getFill();

				if (isset($fill->startcolorIndex)) {
					$startColor = self::_readColor($fill->startcolorIndex,$this->_palette,$this->_version);
					$fill->getStartColor()->setRGB($startColor['rgb']);
				}

				if (isset($fill->endcolorIndex)) {
					$endColor = self::_readColor($fill->endcolorIndex,$this->_palette,$this->_version);
					$fill->getEndColor()->setRGB($endColor['rgb']);
				}

				// border colors
				$top      = $objStyle->getBorders()->getTop();
				$right    = $objStyle->getBorders()->getRight();
				$bottom   = $objStyle->getBorders()->getBottom();
				$left     = $objStyle->getBorders()->getLeft();
				$diagonal = $objStyle->getBorders()->getDiagonal();

				if (isset($top->colorIndex)) {
					$borderTopColor = self::_readColor($top->colorIndex,$this->_palette,$this->_version);
					$top->getColor()->setRGB($borderTopColor['rgb']);
				}

				if (isset($right->colorIndex)) {
					$borderRightColor = self::_readColor($right->colorIndex,$this->_palette,$this->_version);
					$right->getColor()->setRGB($borderRightColor['rgb']);
				}

				if (isset($bottom->colorIndex)) {
					$borderBottomColor = self::_readColor($bottom->colorIndex,$this->_palette,$this->_version);
					$bottom->getColor()->setRGB($borderBottomColor['rgb']);
				}

				if (isset($left->colorIndex)) {
					$borderLeftColor = self::_readColor($left->colorIndex,$this->_palette,$this->_version);
					$left->getColor()->setRGB($borderLeftColor['rgb']);
				}

				if (isset($diagonal->colorIndex)) {
					$borderDiagonalColor = self::_readColor($diagonal->colorIndex,$this->_palette,$this->_version);
					$diagonal->getColor()->setRGB($borderDiagonalColor['rgb']);
				}
			}
		}

		// treat MSODRAWINGGROUP records, workbook-level Escher
		if (!$this->_readDataOnly && $this->_drawingGroupData) {
			$escherWorkbook = new PHPExcel_Shared_Escher();
			$reader = new PHPExcel_Reader_Excel5_Escher($escherWorkbook);
			$escherWorkbook = $reader->load($this->_drawingGroupData);

			// debug Escher stream
			//$debug = new Debug_Escher(new PHPExcel_Shared_Escher());
			//$debug->load($this->_drawingGroupData);
		}

		// Parse the individual sheets
		foreach ($this->_sheets as $sheet) {

			if ($sheet['sheetType'] != 0x00) {
				// 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module
				continue;
			}

			// check if sheet should be skipped
			if (isset($this->_loadSheetsOnly) && !in_array($sheet['name'], $this->_loadSheetsOnly)) {
				continue;
			}

			// add sheet to PHPExcel object
			$this->_phpSheet = $this->_phpExcel->createSheet();
			//	Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in formula
			//		cells... during the load, all formulae should be correct, and we're simply bringing the worksheet
			//		name in line with the formula, not the reverse
			$this->_phpSheet->setTitle($sheet['name'],false);
			$this->_phpSheet->setSheetState($sheet['sheetState']);

			$this->_pos = $sheet['offset'];

			// Initialize isFitToPages. May change after reading SHEETPR record.
			$this->_isFitToPages = false;

			// Initialize drawingData
			$this->_drawingData = '';

			// Initialize objs
			$this->_objs = array();

			// Initialize shared formula parts
			$this->_sharedFormulaParts = array();

			// Initialize shared formulas
			$this->_sharedFormulas = array();

			// Initialize text objs
			$this->_textObjects = array();

			// Initialize cell annotations
			$this->_cellNotes = array();
			$this->textObjRef = -1;

			while ($this->_pos <= $this->_dataSize - 4) {
				$code = self::_GetInt2d($this->_data, $this->_pos);

				switch ($code) {
					case self::XLS_Type_BOF:					$this->_readBof();						break;
					case self::XLS_Type_PRINTGRIDLINES:			$this->_readPrintGridlines();			break;
					case self::XLS_Type_DEFAULTROWHEIGHT:		$this->_readDefaultRowHeight();			break;
					case self::XLS_Type_SHEETPR:				$this->_readSheetPr();					break;
					case self::XLS_Type_HORIZONTALPAGEBREAKS:	$this->_readHorizontalPageBreaks();		break;
					case self::XLS_Type_VERTICALPAGEBREAKS:		$this->_readVerticalPageBreaks();		break;
					case self::XLS_Type_HEADER:					$this->_readHeader();					break;
					case self::XLS_Type_FOOTER:					$this->_readFooter();					break;
					case self::XLS_Type_HCENTER:				$this->_readHcenter();					break;
					case self::XLS_Type_VCENTER:				$this->_readVcenter();					break;
					case self::XLS_Type_LEFTMARGIN:				$this->_readLeftMargin();				break;
					case self::XLS_Type_RIGHTMARGIN:			$this->_readRightMargin();				break;
					case self::XLS_Type_TOPMARGIN:				$this->_readTopMargin();				break;
					case self::XLS_Type_BOTTOMMARGIN:			$this->_readBottomMargin();				break;
					case self::XLS_Type_PAGESETUP:				$this->_readPageSetup();				break;
					case self::XLS_Type_PROTECT:				$this->_readProtect();					break;
					case self::XLS_Type_SCENPROTECT:			$this->_readScenProtect();				break;
					case self::XLS_Type_OBJECTPROTECT:			$this->_readObjectProtect();			break;
					case self::XLS_Type_PASSWORD:				$this->_readPassword();					break;
					case self::XLS_Type_DEFCOLWIDTH:			$this->_readDefColWidth();				break;
					case self::XLS_Type_COLINFO:				$this->_readColInfo();					break;
					case self::XLS_Type_DIMENSION:				$this->_readDefault();					break;
					case self::XLS_Type_ROW:					$this->_readRow();						break;
					case self::XLS_Type_DBCELL:					$this->_readDefault();					break;
					case self::XLS_Type_RK:						$this->_readRk();						break;
					case self::XLS_Type_LABELSST:				$this->_readLabelSst();					break;
					case self::XLS_Type_MULRK:					$this->_readMulRk();					break;
					case self::XLS_Type_NUMBER:					$this->_readNumber();					break;
					case self::XLS_Type_FORMULA:				$this->_readFormula();					break;
					case self::XLS_Type_SHAREDFMLA:				$this->_readSharedFmla();				break;
					case self::XLS_Type_BOOLERR:				$this->_readBoolErr();					break;
					case self::XLS_Type_MULBLANK:				$this->_readMulBlank();					break;
					case self::XLS_Type_LABEL:					$this->_readLabel();					break;
					case self::XLS_Type_BLANK:					$this->_readBlank();					break;
					case self::XLS_Type_MSODRAWING:				$this->_readMsoDrawing();				break;
					case self::XLS_Type_OBJ:					$this->_readObj();						break;
					case self::XLS_Type_WINDOW2:				$this->_readWindow2();					break;
					case self::XLS_Type_PAGELAYOUTVIEW:	$this->_readPageLayoutView();					break;
					case self::XLS_Type_SCL:					$this->_readScl();						break;
					case self::XLS_Type_PANE:					$this->_readPane();						break;
					case self::XLS_Type_SELECTION:				$this->_readSelection();				break;
					case self::XLS_Type_MERGEDCELLS:			$this->_readMergedCells();				break;
					case self::XLS_Type_HYPERLINK:				$this->_readHyperLink();				break;
					case self::XLS_Type_DATAVALIDATIONS:		$this->_readDataValidations();			break;
					case self::XLS_Type_DATAVALIDATION:			$this->_readDataValidation();			break;
					case self::XLS_Type_SHEETLAYOUT:			$this->_readSheetLayout();				break;
					case self::XLS_Type_SHEETPROTECTION:		$this->_readSheetProtection();			break;
					case self::XLS_Type_RANGEPROTECTION:		$this->_readRangeProtection();			break;
					case self::XLS_Type_NOTE:					$this->_readNote();						break;
					//case self::XLS_Type_IMDATA:				$this->_readImData();					break;
					case self::XLS_Type_TXO:					$this->_readTextObject();				break;
					case self::XLS_Type_CONTINUE:				$this->_readContinue();					break;
					case self::XLS_Type_EOF:					$this->_readDefault();					break 2;
					default:									$this->_readDefault();					break;
				}

			}

			// treat MSODRAWING records, sheet-level Escher
			if (!$this->_readDataOnly && $this->_drawingData) {
				$escherWorksheet = new PHPExcel_Shared_Escher();
				$reader = new PHPExcel_Reader_Excel5_Escher($escherWorksheet);
				$escherWorksheet = $reader->load($this->_drawingData);

				// debug Escher stream
				//$debug = new Debug_Escher(new PHPExcel_Shared_Escher());
				//$debug->load($this->_drawingData);

				// get all spContainers in one long array, so they can be mapped to OBJ records
				$allSpContainers = $escherWorksheet->getDgContainer()->getSpgrContainer()->getAllSpContainers();
			}

			// treat OBJ records
			foreach ($this->_objs as $n => $obj) {
//				echo '<hr /><b>Object</b> reference is ',$n,'<br />';
//				var_dump($obj);
//				echo '<br />';

				// the first shape container never has a corresponding OBJ record, hence $n + 1
				if (isset($allSpContainers[$n + 1]) && is_object($allSpContainers[$n + 1])) {
					$spContainer = $allSpContainers[$n + 1];

					// we skip all spContainers that are a part of a group shape since we cannot yet handle those
					if ($spContainer->getNestingLevel() > 1) {
						continue;
					}

					// calculate the width and height of the shape
					list($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($spContainer->getStartCoordinates());
					list($endColumn, $endRow) = PHPExcel_Cell::coordinateFromString($spContainer->getEndCoordinates());

					$startOffsetX = $spContainer->getStartOffsetX();
					$startOffsetY = $spContainer->getStartOffsetY();
					$endOffsetX = $spContainer->getEndOffsetX();
					$endOffsetY = $spContainer->getEndOffsetY();

					$width = PHPExcel_Shared_Excel5::getDistanceX($this->_phpSheet, $startColumn, $startOffsetX, $endColumn, $endOffsetX);
					$height = PHPExcel_Shared_Excel5::getDistanceY($this->_phpSheet, $startRow, $startOffsetY, $endRow, $endOffsetY);

					// calculate offsetX and offsetY of the shape
					$offsetX = $startOffsetX * PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, $startColumn) / 1024;
					$offsetY = $startOffsetY * PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $startRow) / 256;

					switch ($obj['otObjType']) {
						case 0x19:
							// Note
//							echo 'Cell Annotation Object<br />';
//							echo 'Object ID is ',$obj['idObjID'],'<br />';
//
							if (isset($this->_cellNotes[$obj['idObjID']])) {
								$cellNote = $this->_cellNotes[$obj['idObjID']];

								if (isset($this->_textObjects[$obj['idObjID']])) {
									$textObject = $this->_textObjects[$obj['idObjID']];
									$this->_cellNotes[$obj['idObjID']]['objTextData'] = $textObject;
								}
							}
							break;

						case 0x08:
//							echo 'Picture Object<br />';
							// picture

							// get index to BSE entry (1-based)
							$BSEindex = $spContainer->getOPT(0x0104);
							$BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection();
							$BSE = $BSECollection[$BSEindex - 1];
							$blipType = $BSE->getBlipType();

							// need check because some blip types are not supported by Escher reader such as EMF
							if ($blip = $BSE->getBlip()) {
								$ih = imagecreatefromstring($blip->getData());
								$drawing = new PHPExcel_Worksheet_MemoryDrawing();
								$drawing->setImageResource($ih);

								// width, height, offsetX, offsetY
								$drawing->setResizeProportional(false);
								$drawing->setWidth($width);
								$drawing->setHeight($height);
								$drawing->setOffsetX($offsetX);
								$drawing->setOffsetY($offsetY);

								switch ($blipType) {
									case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
										$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG);
										$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG);
										break;

									case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
										$drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG);
										$drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG);
										break;
								}

								$drawing->setWorksheet($this->_phpSheet);
								$drawing->setCoordinates($spContainer->getStartCoordinates());
							}

							break;

						default:
							// other object type
							break;

					}
				}
			}

			// treat SHAREDFMLA records
			if ($this->_version == self::XLS_BIFF8) {
				foreach ($this->_sharedFormulaParts as $cell => $baseCell) {
					list($column, $row) = PHPExcel_Cell::coordinateFromString($cell);
					if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($column, $row, $this->_phpSheet->getTitle()) ) {
						$formula = $this->_getFormulaFromStructure($this->_sharedFormulas[$baseCell], $cell);
						$this->_phpSheet->getCell($cell)->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
					}
				}
			}

			if (!empty($this->_cellNotes)) {
				foreach($this->_cellNotes as $note => $noteDetails) {
					if (!isset($noteDetails['objTextData'])) {
						if (isset($this->_textObjects[$note])) {
							$textObject = $this->_textObjects[$note];
							$noteDetails['objTextData'] = $textObject;
						} else {
							$noteDetails['objTextData']['text'] = '';
						}
					}
//					echo '<b>Cell annotation ',$note,'</b><br />';
//					var_dump($noteDetails);
//					echo '<br />';
					$cellAddress = str_replace('$','',$noteDetails['cellRef']);
					$this->_phpSheet->getComment( $cellAddress )
													->setAuthor( $noteDetails['author'] )
													->setText($this->_parseRichText($noteDetails['objTextData']['text']) );
				}
			}
		}

		// add the named ranges (defined names)
		foreach ($this->_definedname as $definedName) {
			if ($definedName['isBuiltInName']) {
				switch ($definedName['name']) {

				case pack('C', 0x06):
					// print area
					//	in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2
					$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?

					$extractedRanges = array();
					foreach ($ranges as $range) {
						// $range should look like one of these
						//		Foo!$C$7:$J$66
						//		Bar!$A$1:$IV$2

						$explodes = explode('!', $range);	// FIXME: what if sheetname contains exclamation mark?
						$sheetName = trim($explodes[0], "'");

						if (count($explodes) == 2) {
							if (strpos($explodes[1], ':') === FALSE) {
								$explodes[1] = $explodes[1] . ':' . $explodes[1];
							}
							$extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66
						}
					}
					if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) {
						$docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2
					}
					break;

				case pack('C', 0x07):
					// print titles (repeating rows)
					// Assuming BIFF8, there are 3 cases
					// 1. repeating rows
					//		formula looks like this: Sheet!$A$1:$IV$2
					//		rows 1-2 repeat
					// 2. repeating columns
					//		formula looks like this: Sheet!$A$1:$B$65536
					//		columns A-B repeat
					// 3. both repeating rows and repeating columns
					//		formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2

					$ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma?

					foreach ($ranges as $range) {
						// $range should look like this one of these
						//		Sheet!$A$1:$B$65536
						//		Sheet!$A$1:$IV$2

						$explodes = explode('!', $range);

						if (count($explodes) == 2) {
							if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {

								$extractedRange = $explodes[1];
								$extractedRange = str_replace('$', '', $extractedRange);

								$coordinateStrings = explode(':', $extractedRange);
								if (count($coordinateStrings) == 2) {
									list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]);
									list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]);

									if ($firstColumn == 'A' and $lastColumn == 'IV') {
										// then we have repeating rows
										$docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow));
									} elseif ($firstRow == 1 and $lastRow == 65536) {
										// then we have repeating columns
										$docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn));
									}
								}
							}
						}
					}
					break;

				}
			} else {
				// Extract range
				$explodes = explode('!', $definedName['formula']);

				if (count($explodes) == 2) {
					if (($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) ||
						($docSheet = $this->_phpExcel->getSheetByName(trim($explodes[0],"'")))) {
						$extractedRange = $explodes[1];
						$extractedRange = str_replace('$', '', $extractedRange);

						$localOnly = ($definedName['scope'] == 0) ? false : true;

						$scope = ($definedName['scope'] == 0) ?
							null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']);

						$this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope) );
					}
				} else {
					//	Named Value
					//	TODO Provide support for named values
				}
			}
		}

		return $this->_phpExcel;
	}
663892
public function canRead($pFilename)
    {

        //    Office                    xmlns:o="urn:schemas-microsoft-com:office:office"
        //    Excel                    xmlns:x="urn:schemas-microsoft-com:office:excel"
        //    XML Spreadsheet            xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
        //    Spreadsheet component    xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
        //    XML schema                 xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
        //    XML data type            xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
        //    MS-persist recordset    xmlns:rs="urn:schemas-microsoft-com:rowset"
        //    Rowset                    xmlns:z="#RowsetSchema"
        //

        $signature = array(
                '<?xml version="1.0"',
                '<?mso-application progid="Excel.Sheet"?>'
            );

        // Open file
        $this->openFile($pFilename);
        $fileHandle = $this->fileHandle;
        
        // Read sample data (first 2 KB will do)
        $data = fread($fileHandle, 2048);
        fclose($fileHandle);

        $valid = true;
        foreach ($signature as $match) {
            // every part of the signature must be present
            if (strpos($data, $match) === false) {
                $valid = false;
                break;
            }
        }

        //    Retrieve charset encoding
        if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um', $data, $matches)) {
            $this->charSet = strtoupper($matches[1]);
        }
//        echo 'Character Set is ', $this->charSet,'<br />';

        return $valid;
    }
340236
public function listWorksheetInfo($pFilename)
	{
		// Check if file exists
		if (!file_exists($pFilename)) {
			throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
		}

		$worksheetInfo = array();

		// Read the OLE file
		$this->_loadOLE($pFilename);

		// total byte size of Excel data (workbook global substream + sheet substreams)
		$this->_dataSize = strlen($this->_data);

		// initialize
		$this->_pos    = 0;
		$this->_sheets = array();

		// Parse Workbook Global Substream
		while ($this->_pos < $this->_dataSize) {
			$code = self::_GetInt2d($this->_data, $this->_pos);

			switch ($code) {
				case self::XLS_Type_BOF:        $this->_readBof();        break;
				case self::XLS_Type_SHEET:      $this->_readSheet();      break;
				case self::XLS_Type_EOF:        $this->_readDefault();    break 2;
				default:                        $this->_readDefault();    break;
			}
		}

		// Parse the individual sheets
		foreach ($this->_sheets as $sheet) {

			if ($sheet['sheetType'] != 0x00) {
				// 0x00: Worksheet
				// 0x02: Chart
				// 0x06: Visual Basic module
				continue;
			}

			$tmpInfo = array();
			$tmpInfo['worksheetName'] = $sheet['name'];
			$tmpInfo['lastColumnLetter'] = 'A';
			$tmpInfo['lastColumnIndex'] = 0;
			$tmpInfo['totalRows'] = 0;
			$tmpInfo['totalColumns'] = 0;

			$this->_pos = $sheet['offset'];

			while ($this->_pos <= $this->_dataSize - 4) {
				$code = self::_GetInt2d($this->_data, $this->_pos);

				switch ($code) {
					case self::XLS_Type_RK:
					case self::XLS_Type_LABELSST:
					case self::XLS_Type_NUMBER:
					case self::XLS_Type_FORMULA:
					case self::XLS_Type_BOOLERR:
					case self::XLS_Type_LABEL:
						$length = self::_GetInt2d($this->_data, $this->_pos + 2);
						$recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length);

						// move stream pointer to next record
						$this->_pos += 4 + $length;

						$rowIndex = self::_GetInt2d($recordData, 0) + 1;
						$columnIndex = self::_GetInt2d($recordData, 2);

						$tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex);
						$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
						break;
					case self::XLS_Type_BOF:      $this->_readBof();          break;
					case self::XLS_Type_EOF:      $this->_readDefault();      break 2;
					default:                      $this->_readDefault();      break;
				}
			}

			$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
			$tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;

			$worksheetInfo[] = $tmpInfo;
		}

		return $worksheetInfo;
	}
429667
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 PHPExcel_Writer_Exception("File $pFile does not exist");
		}
	}
604059
public function listWorksheetInfo($pFilename)
	{
		// Check if file exists
		if (!file_exists($pFilename)) {
			throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
		}

		$worksheetInfo = array();

		$zip = new ZipArchive;
		$zip->open($pFilename);

		$rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels")); //~ http://schemas.openxmlformats.org/package/2006/relationships");
		foreach ($rels->Relationship as $rel) {
			if ($rel["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") {
				$dir = dirname($rel["Target"]);
				$relsWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels"));  //~ http://schemas.openxmlformats.org/package/2006/relationships");
				$relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");

				$worksheets = array();
				foreach ($relsWorkbook->Relationship as $ele) {
					if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet") {
						$worksheets[(string) $ele["Id"]] = $ele["Target"];
					}
				}

				$xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}"));  //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
				if ($xmlWorkbook->sheets) {
					$dir = dirname($rel["Target"]);
					foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
						$tmpInfo = array(
							'worksheetName' => (string) $eleSheet["name"],
							'lastColumnLetter' => 'A',
							'lastColumnIndex' => 0,
							'totalRows' => 0,
							'totalColumns' => 0,
						);

						$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];

						$xml = new XMLReader();
						$res = $xml->open('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet");
						$xml->setParserProperty(2,true);

						$currCells = 0;
						while ($xml->read()) {
							if ($xml->name == 'row' && $xml->nodeType == XMLReader::ELEMENT) {
								$row = $xml->getAttribute('r');
								$tmpInfo['totalRows'] = $row;
								$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
								$currCells = 0;
							} elseif ($xml->name == 'c' && $xml->nodeType == XMLReader::ELEMENT) {
								$currCells++;
							}
						}
						$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells);
						$xml->close();

						$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
						$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);

						$worksheetInfo[] = $tmpInfo;
					}
				}
			}
		}

		$zip->close();

		return $worksheetInfo;
	}
1022461
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;
		rewind($fileHandle);

		$worksheetInfo = array();
		$worksheetInfo[0]['worksheetName'] = 'Worksheet';
		$worksheetInfo[0]['lastColumnLetter'] = 'A';
		$worksheetInfo[0]['lastColumnIndex'] = 0;
		$worksheetInfo[0]['totalRows'] = 0;
		$worksheetInfo[0]['totalColumns'] = 0;

		// Loop through file
		$rowData = array();

		// loop through one row (line) at a time in the file
		$rowIndex = 0;
		while (($rowData = fgets($fileHandle)) !== FALSE) {
			$columnIndex = 0;

			// convert SYLK encoded $rowData to UTF-8
			$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);

			// explode each row at semicolons while taking into account that literal semicolon (;)
			// is escaped like this (;;)
			$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));

			$dataType = array_shift($rowData);
			if ($dataType == 'C') {
				//  Read cell value data
				foreach($rowData as $rowDatum) {
					switch($rowDatum{0}) {
						case 'C' :
						case 'X' :
							$columnIndex = substr($rowDatum,1) - 1;
							break;
						case 'R' :
						case 'Y' :
							$rowIndex = substr($rowDatum,1);
							break;
					}

					$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
					$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
				}
			}
		}

		$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
		$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;

		// Close file
		fclose($fileHandle);

		return $worksheetInfo;
	}
1264339
public function createWorkbookFromTemplate($templateFileName)
    {

        if ($templateFileName == '')
            throw new Exception('Template file not specified');
        //build URI to merge Docs
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '?templatefile=' . $templateFileName;
        //sign URI
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'PUT');
        $json = json_decode($responseStream);
        return $json;

    }
1315880
public static function load($pClassName)
    {
        if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
            // Either already loaded, or not a PHPExcel class request
            return false;
        }

        $pClassFilePath = PHPEXCEL_ROOT .
            str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
            '.php';

        if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
            // Can't load
            return false;
        }

        require($pClassFilePath);
    }
114251
public function listWorksheetNames($pFilename)
	{
		// Check if file exists
		if (!file_exists($pFilename)) {
			throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
		}
		if (!$this->canRead($pFilename)) {
			throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
		}

		$worksheetNames = array();

		$xml = simplexml_load_file($pFilename);
		$namespaces = $xml->getNamespaces(true);

		$xml_ss = $xml->children($namespaces['ss']);
		foreach($xml_ss->Worksheet as $worksheet) {
			$worksheet_ss = $worksheet->attributes($namespaces['ss']);
			$worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet);
		}

		return $worksheetNames;
	}
1037092
public function listWorksheetNames($pFilename)
	{
		// Check if file exists
		if (!file_exists($pFilename)) {
			throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
		}

		$zip = new ZipArchive;
		if (!$zip->open($pFilename)) {
			throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
		}

		$worksheetNames = array();

		$xml = new XMLReader();
		$res = $xml->open('zip://'.realpath($pFilename).'#content.xml');
		$xml->setParserProperty(2,true);

		//	Step into the first level of content of the XML
		$xml->read();
		while ($xml->read()) {
			//	Quickly jump through to the office:body node
			while ($xml->name !== 'office:body') {
				if ($xml->isEmptyElement)
					$xml->read();
				else
					$xml->next();
			}
			//	Now read each node until we find our first table:table node
			while ($xml->read()) {
				if ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT) {
					//	Loop through each table:table node reading the table:name attribute for each worksheet name
					do {
						$worksheetNames[] = $xml->getAttribute('table:name');
						$xml->next();
					} while ($xml->name == 'table:table' && $xml->nodeType == XMLReader::ELEMENT);
				}
			}
		}

		return $worksheetNames;
	}
887373
public function listWorksheetNames($pFilename)
    {
        // Check if file exists
        if (!file_exists($pFilename)) {
            throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
        }

        $xml = new XMLReader();
        $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
        $xml->setParserProperty(2, true);

        $worksheetNames = array();
        while ($xml->read()) {
            if ($xml->name == 'gnm:SheetName' && $xml->nodeType == XMLReader::ELEMENT) {
                $xml->read();    //    Move onto the value node
                $worksheetNames[] = (string) $xml->value;
            } elseif ($xml->name == 'gnm:Sheets') {
                //    break out of the loop once we've got our sheet names rather than parse the entire file
                break;
            }
        }

        return $worksheetNames;
    }
604396
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '')
    {
        if ($oldName == '') {
            return;
        }

        foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
            foreach ($sheet->getCellCollection(false) as $cellID) {
                $cell = $sheet->getCell($cellID);
                if (($cell !== null) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) {
                    $formula = $cell->getValue();
                    if (strpos($formula, $oldName) !== false) {
                        $formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
                        $formula = str_replace($oldName . "!", $newName . "!", $formula);
                        $cell->setValueExplicit($formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
                    }
                }
            }
        }
    }
941023
public function loadExpectationFromFile($fileName)
    {
        $this->logger->debug("Loading expectation file $fileName");
        $content = file_get_contents($fileName);
        $data = @json_decode($content, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \Exception(json_last_error_msg());
        }
        /** @var Mcustiel\Phiremock\Domain\Expectation $expectation */
        $expectation = $this->converter->convert($data);
        $this->validateExpectationOrThrowException($expectation, $this->logger);

        $this->logger->debug('Parsed expectation: ' . var_export($expectation, true));
        $this->storage->addExpectation($expectation);
        // As we have no API to modify expectation parsed the same object could be used for backup.
        // On futher changes when $expectation modifications are possible something like deep-copy
        // should be used to clone expectation.
        $this->backup->addExpectation($expectation);
    }
1044581
public function parse($rawFileName)
    {
        $fileName = \realpath($rawFileName);

        if (!\is_file($fileName)) {
            throw new FileNotFoundException($rawFileName);
        }

        $rootDir = \dirname($fileName);
        $ramlString = \file_get_contents($fileName);

        $ramlData = $this->parseRamlString($ramlString, $rootDir);

        return $this->parseRamlData($ramlData, $rootDir);
    }
189314
public function listWorksheetInfo($pFilename)
    {
        // Check if file exists
        if (!file_exists($pFilename)) {
            throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
        }

        $xml = new XMLReader();
        $xml->xml($this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions());
        $xml->setParserProperty(2, true);

        $worksheetInfo = array();
        while ($xml->read()) {
            if ($xml->name == 'gnm:Sheet' && $xml->nodeType == XMLReader::ELEMENT) {
                $tmpInfo = array(
                    'worksheetName' => '',
                    'lastColumnLetter' => 'A',
                    'lastColumnIndex' => 0,
                    'totalRows' => 0,
                    'totalColumns' => 0,
                );

                while ($xml->read()) {
                    if ($xml->name == 'gnm:Name' && $xml->nodeType == XMLReader::ELEMENT) {
                        $xml->read();    //    Move onto the value node
                        $tmpInfo['worksheetName'] = (string) $xml->value;
                    } elseif ($xml->name == 'gnm:MaxCol' && $xml->nodeType == XMLReader::ELEMENT) {
                        $xml->read();    //    Move onto the value node
                        $tmpInfo['lastColumnIndex'] = (int) $xml->value;
                        $tmpInfo['totalColumns'] = (int) $xml->value + 1;
                    } elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) {
                        $xml->read();    //    Move onto the value node
                        $tmpInfo['totalRows'] = (int) $xml->value + 1;
                        break;
                    }
                }
                $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
                $worksheetInfo[] = $tmpInfo;
            }
        }

        return $worksheetInfo;
    }
563190
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
	{
		// 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;
		rewind($fileHandle);

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

		$fromFormats	= array('\-',	'\ ');
		$toFormats		= array('-',	' ');

		// Loop through file
		$rowData = array();
		$column = $row = '';

		// loop through one row (line) at a time in the file
		while (($rowData = fgets($fileHandle)) !== FALSE) {

			// convert SYLK encoded $rowData to UTF-8
			$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);

			// explode each row at semicolons while taking into account that literal semicolon (;)
			// is escaped like this (;;)
			$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));

			$dataType = array_shift($rowData);
			//	Read shared styles
			if ($dataType == 'P') {
				$formatArray = array();
				foreach($rowData as $rowDatum) {
					switch($rowDatum{0}) {
						case 'P' :	$formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
									break;
						case 'E' :
						case 'F' :	$formatArray['font']['name'] = substr($rowDatum,1);
									break;
						case 'L' :	$formatArray['font']['size'] = substr($rowDatum,1);
									break;
						case 'S' :	$styleSettings = substr($rowDatum,1);
									for ($i=0;$i<strlen($styleSettings);++$i) {
										switch ($styleSettings{$i}) {
											case 'I' :	$formatArray['font']['italic'] = true;
														break;
											case 'D' :	$formatArray['font']['bold'] = true;
														break;
											case 'T' :	$formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
											case 'B' :	$formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
											case 'L' :	$formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
											case 'R' :	$formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
										}
									}
									break;
					}
				}
				$this->_formats['P'.$this->_format++] = $formatArray;
			//	Read cell value data
			} elseif ($dataType == 'C') {
				$hasCalculatedValue = false;
				$cellData = $cellDataFormula = '';
				foreach($rowData as $rowDatum) {
					switch($rowDatum{0}) {
						case 'C' :
						case 'X' :	$column = substr($rowDatum,1);
									break;
						case 'R' :
						case 'Y' :	$row = substr($rowDatum,1);
									break;
						case 'K' :	$cellData = substr($rowDatum,1);
									break;
						case 'E' :	$cellDataFormula = '='.substr($rowDatum,1);
									//	Convert R1C1 style references to A1 style references (but only when not quoted)
									$temp = explode('"',$cellDataFormula);
									$key = false;
									foreach($temp as &$value) {
										//	Only count/replace in alternate array entries
										if ($key = !$key) {
											preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
											//	Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
											//		through the formula from left to right. Reversing means that we work right to left.through
											//		the formula
											$cellReferences = array_reverse($cellReferences);
											//	Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
											//		then modify the formula to use that new reference
											foreach($cellReferences as $cellReference) {
												$rowReference = $cellReference[2][0];
												//	Empty R reference is the current row
												if ($rowReference == '') $rowReference = $row;
												//	Bracketed R references are relative to the current row
												if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
												$columnReference = $cellReference[4][0];
												//	Empty C reference is the current column
												if ($columnReference == '') $columnReference = $column;
												//	Bracketed C references are relative to the current column
												if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
												$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;

												$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
											}
										}
									}
									unset($value);
									//	Then rebuild the formula string
									$cellDataFormula = implode('"',$temp);
									$hasCalculatedValue = true;
									break;
					}
				}
				$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
				$cellData = PHPExcel_Calculation::_unwrapResult($cellData);

				// Set cell value
				$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
				if ($hasCalculatedValue) {
					$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
					$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
				}
			//	Read cell formatting
			} elseif ($dataType == 'F') {
				$formatStyle = $columnWidth = $styleSettings = '';
				$styleData = array();
				foreach($rowData as $rowDatum) {
					switch($rowDatum{0}) {
						case 'C' :
						case 'X' :	$column = substr($rowDatum,1);
									break;
						case 'R' :
						case 'Y' :	$row = substr($rowDatum,1);
									break;
						case 'P' :	$formatStyle = $rowDatum;
									break;
						case 'W' :	list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
									break;
						case 'S' :	$styleSettings = substr($rowDatum,1);
									for ($i=0;$i<strlen($styleSettings);++$i) {
										switch ($styleSettings{$i}) {
											case 'I' :	$styleData['font']['italic'] = true;
														break;
											case 'D' :	$styleData['font']['bold'] = true;
														break;
											case 'T' :	$styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
											case 'B' :	$styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
											case 'L' :	$styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
											case 'R' :	$styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
														break;
										}
									}
									break;
					}
				}
				if (($formatStyle > '') && ($column > '') && ($row > '')) {
					$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
					if (isset($this->_formats[$formatStyle])) {
						$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
					}
				}
				if ((!empty($styleData)) && ($column > '') && ($row > '')) {
					$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
					$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
				}
				if ($columnWidth > '') {
					if ($startCol == $endCol) {
						$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
						$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
					} else {
						$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
						$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
						$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
						do {
							$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
						} while ($startCol != $endCol);
					}
				}
			} else {
				foreach($rowData as $rowDatum) {
					switch($rowDatum{0}) {
						case 'C' :
						case 'X' :	$column = substr($rowDatum,1);
									break;
						case 'R' :
						case 'Y' :	$row = substr($rowDatum,1);
									break;
					}
				}
			}
		}

		// Close file
		fclose($fileHandle);

		// Return
		return $objPHPExcel;
	}
659798
protected function _getReader() {
        /**
         * Note: this is now autoloaded by Composer
         */
        //require APPLICATION_PATH.'/../garp/library/Garp/3rdParty/PHPExcel/Classes/PHPExcel.php';

        $inputFileType = PHPExcel_IOFactory::identify($this->_importFile);
        // HTML is never correct. Just default to Excel2007
        // @todo Fix this. It should be able to determine the filetype correctly.
        if ($inputFileType === 'HTML') {
            $inputFileType = 'Excel2007';
        }
        $reader = PHPExcel_IOFactory::createReader($inputFileType);
        // we are only interested in cell values (not formatting etc.), so set readDataOnly to true
        // $reader->setReadDataOnly(true);
        $phpexcel = $reader->load($this->_importFile);

        return $phpexcel;
    }