Merge remote-tracking branch 'origin/experimental' into develop

This commit is contained in:
Dominik Bonsch 2013-02-09 12:32:03 +01:00
commit 4e8dea7883
5 changed files with 668 additions and 650 deletions

View File

@ -227,7 +227,9 @@ class PHPExcel
public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL)
{
if ($this->sheetNameExists($pSheet->getTitle())) {
throw new PHPExcel_Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first.");
throw new PHPExcel_Exception(
"Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first."
);
}
if($iSheetIndex === NULL) {
@ -260,8 +262,13 @@ class PHPExcel
*/
public function removeSheetByIndex($pIndex = 0)
{
if ($pIndex > count($this->_workSheetCollection) - 1) {
throw new PHPExcel_Exception("Sheet index is out of bounds.");
$numSheets = count($this->_workSheetCollection);
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
"You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
);
} else {
array_splice($this->_workSheetCollection, $pIndex, 1);
}
@ -282,8 +289,13 @@ class PHPExcel
*/
public function getSheet($pIndex = 0)
{
if ($pIndex > count($this->_workSheetCollection) - 1) {
throw new PHPExcel_Exception("Sheet index is out of bounds.");
$numSheets = count($this->_workSheetCollection);
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
);
} else {
return $this->_workSheetCollection[$pIndex];
}
@ -389,8 +401,12 @@ class PHPExcel
*/
public function setActiveSheetIndex($pIndex = 0)
{
if ($pIndex > count($this->_workSheetCollection) - 1) {
throw new PHPExcel_Exception("Active sheet index is out of bounds.");
$numSheets = count($this->_workSheetCollection);
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
"You tried to set a sheet active by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
);
} else {
$this->_activeSheetIndex = $pIndex;
}

View File

@ -43,7 +43,6 @@ class PHPExcel_DocumentProperties
const PROPERTY_TYPE_STRING = 's';
const PROPERTY_TYPE_UNKNOWN = 'u';
/**
* Creator
*

View File

@ -252,19 +252,22 @@ class PHPExcel_Shared_OLERead {
$name = str_replace("\x00", "", substr($d,0,$nameSize));
$this->props[] = array (
'name' => $name,
'type' => $type,
'startBlock' => $startBlock,
'size' => $size);
// tmp helper to simplify checks
$upName = strtoupper($name);
// Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook)
if (($name == 'Workbook') || ($name == 'Book') || ($name == 'WORKBOOK') || ($name == 'BOOK')) {
if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) {
$this->wrkbook = count($this->props) - 1;
}
else if ( $upName === 'ROOT ENTRY' || $upName === 'R') {
// Root entry
if ($name == 'Root Entry' || $name == 'ROOT ENTRY' || $name == 'R') {
$this->rootentry = count($this->props) - 1;
}