A mass of small changes including

* Implementation of the Excel SUMIFS function
 * Fixes for Readers to handle various malformed spreadsheet file formats
 * Better error handling in Iterators
 * Suppression of Chart formula evaluation on save if formula evaluation is disabled
 * Changes for PHP7
 * Hopefully fixed a memory issue with unsetting PHPExcel object failing to unset the calculation engine
This commit is contained in:
MarkBaker 2015-11-15 18:04:45 +00:00
parent 6a8fca703c
commit ecdb406d4d
26 changed files with 234 additions and 89 deletions

View File

@ -364,7 +364,7 @@ class PHPExcel
public function __construct() public function __construct()
{ {
$this->uniqueID = uniqid(); $this->uniqueID = uniqid();
$this->calculationEngine = PHPExcel_Calculation::getInstance($this); $this->calculationEngine = new PHPExcel_Calculation($this);
// Initialise worksheet collection and add one worksheet // Initialise worksheet collection and add one worksheet
$this->workSheetCollection = array(); $this->workSheetCollection = array();
@ -395,7 +395,7 @@ class PHPExcel
*/ */
public function __destruct() public function __destruct()
{ {
PHPExcel_Calculation::unsetInstance($this); $this->calculationEngine = null;
$this->disconnectWorksheets(); $this->disconnectWorksheets();
} }

View File

@ -1497,7 +1497,7 @@ class PHPExcel_Calculation
'OFFSET' => array( 'OFFSET' => array(
'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE, 'category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET', 'functionCall' => 'PHPExcel_Calculation_LookupRef::OFFSET',
'argumentCount' => '3,5', 'argumentCount' => '3-5',
'passCellReference' => true, 'passCellReference' => true,
'passByReference' => array(true) 'passByReference' => array(true)
), ),
@ -1814,8 +1814,8 @@ class PHPExcel_Calculation
), ),
'SUMIFS' => array( 'SUMIFS' => array(
'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY', 'functionCall' => 'PHPExcel_Calculation_MathTrig::SUMIFS',
'argumentCount' => '?' 'argumentCount' => '3+'
), ),
'SUMPRODUCT' => array( 'SUMPRODUCT' => array(
'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG, 'category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
@ -2068,14 +2068,10 @@ class PHPExcel_Calculation
); );
private function __construct(PHPExcel $workbook = null) public function __construct(PHPExcel $workbook = null)
{ {
$this->delta = 1 * pow(10, 0 - ini_get('precision')); $this->delta = 1 * pow(10, 0 - ini_get('precision'));
if ($workbook !== null) {
self::$workbookSets[$workbook->getID()] = $this;
}
$this->workbook = $workbook; $this->workbook = $workbook;
$this->cyclicReferenceStack = new PHPExcel_CalcEngine_CyclicReferenceStack(); $this->cyclicReferenceStack = new PHPExcel_CalcEngine_CyclicReferenceStack();
$this->_debugLog = new PHPExcel_CalcEngine_Logger($this->cyclicReferenceStack); $this->_debugLog = new PHPExcel_CalcEngine_Logger($this->cyclicReferenceStack);
@ -2104,16 +2100,15 @@ class PHPExcel_Calculation
public static function getInstance(PHPExcel $workbook = null) public static function getInstance(PHPExcel $workbook = null)
{ {
if ($workbook !== null) { if ($workbook !== null) {
if (isset(self::$workbookSets[$workbook->getID()])) { $instance = $workbook->getCalculationEngine();
return self::$workbookSets[$workbook->getID()]; if (isset($instance)) {
return $instance;
} }
return new PHPExcel_Calculation($workbook);
} }
if (!isset(self::$instance) || (self::$instance === null)) { if (!isset(self::$instance) || (self::$instance === null)) {
self::$instance = new PHPExcel_Calculation(); self::$instance = new PHPExcel_Calculation();
} }
return self::$instance; return self::$instance;
} }
@ -2121,15 +2116,10 @@ class PHPExcel_Calculation
* Unset an instance of this class * Unset an instance of this class
* *
* @access public * @access public
* @param PHPExcel $workbook Injected workbook identifying the instance to unset
*/ */
public static function unsetInstance(PHPExcel $workbook = null) public function __destruct()
{ {
if ($workbook !== null) { $this->workbook = null;
if (isset(self::$workbookSets[$workbook->getID()])) {
unset(self::$workbookSets[$workbook->getID()]);
}
}
} }
/** /**

View File

@ -555,10 +555,8 @@ class PHPExcel_Calculation_Functions
case 'float': case 'float':
case 'integer': case 'integer':
return $value; return $value;
break;
case 'boolean': case 'boolean':
return (integer) $value; return (integer) $value;
break;
case 'string': case 'string':
// Errors // Errors
if ((strlen($value) > 0) && ($value{0} == '#')) { if ((strlen($value) > 0) && ($value{0} == '#')) {

View File

@ -1220,6 +1220,66 @@ class PHPExcel_Calculation_MathTrig
} }
/**
* SUMIFS
*
* Counts the number of cells that contain numbers within the list of arguments
*
* Excel Function:
* SUMIFS(value1[,value2[, ...]],condition)
*
* @access public
* @category Mathematical and Trigonometric Functions
* @param mixed $arg,... Data values
* @param string $condition The criteria that defines which cells will be summed.
* @return float
*/
public static function SUMIFS() {
$arrayList = func_get_args();
$sumArgs = PHPExcel_Calculation_Functions::flattenArray(array_shift($arrayList));
while (count($arrayList) > 0) {
$aArgsArray[] = PHPExcel_Calculation_Functions::flattenArray(array_shift($arrayList));
$conditions[] = PHPExcel_Calculation_Functions::ifCondition(array_shift($arrayList));
}
// Loop through each set of arguments and conditions
foreach ($conditions as $index => $condition) {
$aArgs = $aArgsArray[$index];
$wildcard = false;
if ((strpos($condition, '*') !== false) || (strpos($condition, '?') !== false)) {
// * and ? are wildcard characters.
// Use ~* and ~? for literal star and question mark
// Code logic doesn't yet handle escaping
$condition = trim(ltrim($condition, '=<>'), '"');
$wildcard = true;
}
// Loop through arguments
foreach ($aArgs as $key => $arg) {
if ($wildcard) {
if (!fnmatch($condition, $arg, FNM_CASEFOLD)) {
// Is it a value within our criteria
$sumArgs[$key] = 0.0;
}
} else {
if (!is_numeric($arg)) {
$arg = PHPExcel_Calculation::wrapResult(strtoupper($arg));
}
$testCondition = '='.$arg.$condition;
if (!PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
// Is it a value within our criteria
$sumArgs[$key] = 0.0;
}
}
}
}
// Return
return array_sum($sumArgs);
}
/** /**
* SUMPRODUCT * SUMPRODUCT
* *

View File

@ -401,11 +401,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$style_ss = $style->attributes($namespaces['ss']); $style_ss = $style->attributes($namespaces['ss']);
$styleID = (string) $style_ss['ID']; $styleID = (string) $style_ss['ID'];
// echo 'Style ID = '.$styleID.'<br />'; // echo 'Style ID = '.$styleID.'<br />';
if ($styleID == 'Default') { $this->styles[$styleID] = (isset($this->styles['Default'])) ? $this->styles['Default'] : array();
$this->styles['Default'] = array();
} else {
$this->styles[$styleID] = $this->styles['Default'];
}
foreach ($style as $styleType => $styleData) { foreach ($style as $styleType => $styleData) {
$styleAttributes = $styleData->attributes($namespaces['ss']); $styleAttributes = $styleData->attributes($namespaces['ss']);
// echo $styleType.'<br />'; // echo $styleType.'<br />';

View File

@ -307,10 +307,17 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$fileName = PHPExcel_Shared_File::realpath($fileName); $fileName = PHPExcel_Shared_File::realpath($fileName);
// Sadly, some 3rd party xlsx generators don't use consistent case for filenaming
// so we need to load case-insensitively from the zip file
// Apache POI fixes // Apache POI fixes
$contents = $archive->getFromName($fileName); $contents = $archive->getFromIndex(
$archive->locateName($fileName, ZIPARCHIVE::FL_NOCASE)
);
if ($contents === false) { if ($contents === false) {
$contents = $archive->getFromName(substr($fileName, 1)); $contents = $archive->getFromIndex(
$archive->locateName(substr($fileName, 1), ZIPARCHIVE::FL_NOCASE)
);
} }
return $contents; return $contents;

View File

@ -351,10 +351,6 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
if (empty($seriesVal)) {
$seriesVal = null;
}
return array( return array(
'formatCode' => $formatCode, 'formatCode' => $formatCode,
'pointCount' => $pointCount, 'pointCount' => $pointCount,

View File

@ -116,18 +116,30 @@ class PHPExcel_Shared_CodePage
return 'CP950'; // Macintosh Chinese Traditional return 'CP950'; // Macintosh Chinese Traditional
case 10003: case 10003:
return 'CP1361'; // Macintosh Korean return 'CP1361'; // Macintosh Korean
case 10004:
return 'MACARABIC'; // Apple Arabic
case 10005:
return 'MACHEBREW'; // Apple Hebrew
case 10006: case 10006:
return 'MACGREEK'; // Macintosh Greek return 'MACGREEK'; // Macintosh Greek
case 10007: case 10007:
return 'MACCYRILLIC'; // Macintosh Cyrillic return 'MACCYRILLIC'; // Macintosh Cyrillic
case 10008: case 10008:
return 'CP936'; // Macintosh - Simplified Chinese (GB 2312) return 'CP936'; // Macintosh - Simplified Chinese (GB 2312)
case 10010:
return 'MACROMANIA'; // Macintosh Romania
case 10017:
return 'MACUKRAINE'; // Macintosh Ukraine
case 10021:
return 'MACTHAI'; // Macintosh Thai
case 10029: case 10029:
return 'MACCENTRALEUROPE'; // Macintosh Central Europe return 'MACCENTRALEUROPE'; // Macintosh Central Europe
case 10079: case 10079:
return 'MACICELAND'; // Macintosh Icelandic return 'MACICELAND'; // Macintosh Icelandic
case 10081: case 10081:
return 'MACTURKISH'; // Macintosh Turkish return 'MACTURKISH'; // Macintosh Turkish
case 10082:
return 'MACCROATIAN'; // Macintosh Croatian
case 21010: case 21010:
return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
case 32768: case 32768:

View File

@ -107,17 +107,19 @@ class PHPExcel_Shared_ZipArchive
*/ */
public function locateName($fileName) public function locateName($fileName)
{ {
$fileName = strtolower($fileName);
$list = $this->zip->listContent(); $list = $this->zip->listContent();
$listCount = count($list); $listCount = count($list);
$list_index = -1; $index = -1;
for ($i = 0; $i < $listCount; ++$i) { for ($i = 0; $i < $listCount; ++$i) {
if (strtolower($list[$i]["filename"]) == strtolower($fileName) || if (strtolower($list[$i]["filename"]) == $fileName ||
strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) { strtolower($list[$i]["stored_filename"]) == $fileName) {
$list_index = $i; $index = $i;
break; break;
} }
} }
return ($list_index > -1); return ($index > -1) ? $index : false;
} }
/** /**
@ -128,32 +130,30 @@ class PHPExcel_Shared_ZipArchive
*/ */
public function getFromName($fileName) public function getFromName($fileName)
{ {
$list = $this->zip->listContent(); $index = $this->locateName($fileName);
$listCount = count($list);
$list_index = -1; if ($index !== false) {
for ($i = 0; $i < $listCount; ++$i) { $extracted = $this->getFromIndex($index);
if (strtolower($list[$i]["filename"]) == strtolower($fileName) || } else {
strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) { $fileName = substr($fileName, 1);
$list_index = $i; $index = $this->locateName($fileName);
break; if ($index === false) {
return false;
} }
$extracted = $this->zip->getFromIndex($index);
} }
$extracted = ""; $contents = $extracted;
if ($list_index != -1) { if ((is_array($extracted)) && ($extracted != 0)) {
$extracted = $this->zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING); $contents = $extracted[0]["content"];
} else {
$filename = substr($fileName, 1);
$list_index = -1;
for ($i = 0; $i < $listCount; ++$i) {
if (strtolower($list[$i]["filename"]) == strtolower($fileName) ||
strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) {
$list_index = $i;
break;
} }
return $contents;
} }
$extracted = $this->zip->extractByIndex($list_index, PCLZIP_OPT_EXTRACT_AS_STRING);
} public function getFromIndex($index) {
$extracted = $this->zip->extractByIndex($index, PCLZIP_OPT_EXTRACT_AS_STRING);
$contents = '';
if ((is_array($extracted)) && ($extracted != 0)) { if ((is_array($extracted)) && ($extracted != 0)) {
$contents = $extracted[0]["content"]; $contents = $extracted[0]["content"];
} }

View File

@ -861,10 +861,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->title = $pValue; $this->title = $pValue;
$this->dirty = true; $this->dirty = true;
if ($this->parent) { if ($this->parent && $this->parent->getCalculationEngine()) {
// New title // New title
$newTitle = $this->getTitle(); $newTitle = $this->getTitle();
PHPExcel_Calculation::getInstance($this->parent) $this->parent->getCalculationEngine()
->renameCalculationCacheForWorksheet($oldTitle, $newTitle); ->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
if ($updateFormulaCellReferences) { if ($updateFormulaCellReferences) {
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->parent, $oldTitle, $newTitle); PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->parent, $oldTitle, $newTitle);

View File

@ -85,11 +85,19 @@ class PHPExcel_Worksheet_ColumnIterator implements Iterator
* *
* @param integer $startColumn The column address at which to start iterating * @param integer $startColumn The column address at which to start iterating
* @return PHPExcel_Worksheet_ColumnIterator * @return PHPExcel_Worksheet_ColumnIterator
* @throws PHPExcel_Exception
*/ */
public function resetStart($startColumn = 'A') public function resetStart($startColumn = 'A')
{ {
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1; $startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
if ($startColumnIndex > PHPExcel_Cell::columnIndexFromString($this->subject->getHighestColumn()) - 1) {
throw new PHPExcel_Exception("Start column ({$startColumn}) is beyond highest column ({$this->subject->getHighestColumn()})");
}
$this->startColumn = $startColumnIndex; $this->startColumn = $startColumnIndex;
if ($this->endColumn < $this->startColumn) {
$this->endColumn = $this->startColumn;
}
$this->seek($startColumn); $this->seek($startColumn);
return $this; return $this;

View File

@ -64,7 +64,7 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* @param integer $startRow The row number at which to start iterating * @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating * @param integer $endRow Optionally, the row number at which to stop iterating
*/ */
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) public function __construct(PHPExcel_Worksheet $subject, $startRow = 1, $endRow = null)
{ {
// Set subject // Set subject
$this->subject = $subject; $this->subject = $subject;
@ -85,10 +85,18 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* *
* @param integer $startRow The row number at which to start iterating * @param integer $startRow The row number at which to start iterating
* @return PHPExcel_Worksheet_RowIterator * @return PHPExcel_Worksheet_RowIterator
* @throws PHPExcel_Exception
*/ */
public function resetStart($startRow = 1) public function resetStart($startRow = 1)
{ {
if ($startRow > $this->subject->getHighestRow()) {
throw new PHPExcel_Exception("Start row ({$startRow}) is beyond highest row ({$this->subject->getHighestRow()})");
}
$this->startRow = $startRow; $this->startRow = $startRow;
if ($this->endRow < $this->startRow) {
$this->endRow = $this->startRow;
}
$this->seek($startRow); $this->seek($startRow);
return $this; return $this;

View File

@ -297,7 +297,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
$charts = $this->spreadSheet->getSheet($i)->getChartCollection(); $charts = $this->spreadSheet->getSheet($i)->getChartCollection();
if (count($charts) > 0) { if (count($charts) > 0) {
foreach ($charts as $chart) { foreach ($charts as $chart) {
$objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart)); $objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart, $this->preCalculateFormulas));
$chartCount++; $chartCount++;
} }
} }

View File

@ -27,6 +27,8 @@
*/ */
class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart
{ {
protected $calculateCellValues;
/** /**
* Write charts to XML format * Write charts to XML format
* *
@ -35,8 +37,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeChart(PHPExcel_Chart $pChart = null) public function writeChart(PHPExcel_Chart $pChart = null, $calculateCellValues = true)
{ {
$this->calculateCellValues = $calculateCellValues;
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -45,7 +49,9 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY); $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
} }
// Ensure that data series values are up-to-date before we save // Ensure that data series values are up-to-date before we save
if ($this->calculateCellValues) {
$pChart->refresh(); $pChart->refresh();
}
// XML header // XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');

View File

@ -88,7 +88,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
); );
// a custom UI in workbook ? // a custom UI in workbook ?
if ($pPHPExcel->hasRibbon()) { if ($pPHPExcel->hasRibbon()) {
$this->_writeRelationShip( $this->writeRelationShip(
$objWriter, $objWriter,
5, 5,
'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility', 'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
@ -162,7 +162,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
// Relationships for vbaProject if needed // Relationships for vbaProject if needed
// id : just after the last sheet // id : just after the last sheet
if ($pPHPExcel->hasMacros()) { if ($pPHPExcel->hasMacros()) {
$this->_writeRelationShip( $this->writeRelationShip(
$objWriter, $objWriter,
($i + 1 + 3), ($i + 1 + 3),
'http://schemas.microsoft.com/office/2006/relationships/vbaProject', 'http://schemas.microsoft.com/office/2006/relationships/vbaProject',

4
Examples/.gitignore vendored
View File

@ -1,3 +1,5 @@
*.xls *.xls
*.xlsx *.xlsx
*.csv
*.jpg
*.pdf

View File

@ -71,6 +71,14 @@ $objPHPExcel->getActiveSheet()->getRowDimension(8)->setRowHeight(-1);
$objPHPExcel->getActiveSheet()->getStyle('A8')->getAlignment()->setWrapText(true); $objPHPExcel->getActiveSheet()->getStyle('A8')->getAlignment()->setWrapText(true);
$value = "-ValueA\n-Value B\n-Value C";
$objPHPExcel->getActiveSheet()->setCellValue('A10', $value);
$objPHPExcel->getActiveSheet()->getRowDimension(10)->setRowHeight(-1);
$objPHPExcel->getActiveSheet()->getStyle('A10')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('A10')->setQuotePrefix(true);
// Rename worksheet // Rename worksheet
echo date('H:i:s') , " Rename worksheet" , EOL; echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Simple'); $objPHPExcel->getActiveSheet()->setTitle('Simple');

View File

@ -38,15 +38,11 @@ date_default_timezone_set('Europe/London');
require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php'; require_once dirname(__FILE__) . '/../Classes/PHPExcel/IOFactory.php';
if (!file_exists("05featuredemo.xlsx")) {
exit("Please run 05featuredemo.php first." . EOL);
}
echo date('H:i:s') , " Load from Excel2007 file" , EOL; echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$objReader = PHPExcel_IOFactory::createReader('Excel2007'); $objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("05featuredemo.xlsx"); $objPHPExcel = $objReader->load("./templates/28iterators.xlsx");
echo date('H:i:s') , " Iterate worksheets" , EOL; echo date('H:i:s') , " Iterate worksheets by Row" , EOL;
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
echo 'Worksheet - ' , $worksheet->getTitle() , EOL; echo 'Worksheet - ' , $worksheet->getTitle() , EOL;
@ -64,5 +60,23 @@ foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
} }
echo date('H:i:s') , " Iterate worksheets by Column" , EOL;
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
echo 'Worksheet - ' , $worksheet->getTitle() , EOL;
foreach ($worksheet->getColumnIterator() as $column) {
echo ' Column index - ' , $column->getColumnIndex() , EOL;
$cellIterator = $column->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true); // Loop all cells, even if it is not set
foreach ($cellIterator as $cell) {
if (!is_null($cell)) {
echo ' Cell - ' , $cell->getCoordinate() , ' - ' , $cell->getCalculatedValue() , EOL;
}
}
}
}
// Echo memory peak usage // Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;

View File

@ -26,8 +26,11 @@
Planned for 1.8.2 Planned for 1.8.2
- Bugfix: (MBaker) - Fix to getCell() method when cell reference includes a worksheet reference - Bugfix: (MBaker) - Fix to getCell() method when cell reference includes a worksheet reference
- Bugfix: (ncrypthic) Work Item GH-570 - Ignore inlineStr type if formula element exists - Bugfix: (ncrypthic) Work Item GH-570 - Ignore inlineStr type if formula element exists
- Bugfix: (hernst42) Work Item GH-709 - Fixed missing renames of writeRelationShip (from _writeRelationShip)
- General: (umpirsky) Work Item GH-548 - Optimize vlookup() sort - General: (umpirsky) Work Item GH-548 - Optimize vlookup() sort
- Bugfix: (MBaker) Work Item GH-554 - Whitespace after toRichTextObject() - Bugfix: (MBaker) Work Item GH-554 - Whitespace after toRichTextObject()
- Feature: (MBaker) - Initial implementation of SUMIFS() function
- Feature: (MBaker) - Additional codepages
2015-04-30 (v1.8.1): 2015-04-30 (v1.8.1):
@ -68,7 +71,6 @@ Planned for 1.8.2
(see http://projects.webappsec.org/w/page/13247002/XML%20Entity%20Expansion for an explanation of XEE injection) attacks (see http://projects.webappsec.org/w/page/13247002/XML%20Entity%20Expansion for an explanation of XEE injection) attacks
Reference CVE-2015-3542 - Identification of problem courtesy of Dawid Golunski (Pentest Ltd.) Reference CVE-2015-3542 - Identification of problem courtesy of Dawid Golunski (Pentest Ltd.)
2014-03-02 (v1.8.0): 2014-03-02 (v1.8.0):
- Bugfix: (MBaker) Work item CP19830 - Undefined variable: fileHandle in CSV Reader - Bugfix: (MBaker) Work item CP19830 - Undefined variable: fileHandle in CSV Reader
- Bugfix: (MBaker) Work item CP19968 - Out of memory in style/supervisor.php - Bugfix: (MBaker) Work item CP19968 - Out of memory in style/supervisor.php

View File

@ -22,7 +22,7 @@
} }
], ],
"require": { "require": {
"php": ">=5.2.0", "php": "^5.2|^7.0",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-xml": "*", "ext-xml": "*",
"ext-xmlwriter": "*" "ext-xmlwriter": "*"

View File

@ -418,6 +418,22 @@ class MathTrigTest extends PHPUnit_Framework_TestCase
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data'); return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data');
} }
/**
* @dataProvider providerSUMIFS
*/
public function testSUMIFS()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SUMIFS'), $args);
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
public function providerSUMIFS()
{
return new testDataFileIterator('rawTestData/Calculation/MathTrig/SUMIFS.data');
}
/** /**
* @dataProvider providerSUMSQ * @dataProvider providerSUMSQ
*/ */

View File

@ -68,6 +68,14 @@ class ColumnIteratorTest extends PHPUnit_Framework_TestCase
} }
} }
/**
* @expectedException PHPExcel_Exception
*/
public function testStartOutOfRange()
{
$iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'IA', 'IV');
}
/** /**
* @expectedException PHPExcel_Exception * @expectedException PHPExcel_Exception
*/ */

View File

@ -56,16 +56,24 @@ class RowIteratorTest extends PHPUnit_Framework_TestCase
public function testIteratorSeekAndPrev() public function testIteratorSeekAndPrev()
{ {
$iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4); $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4);
$columnIndexResult = 4; $rowIndexResult = 4;
$iterator->seek(4); $iterator->seek($rowIndexResult);
$this->assertEquals($columnIndexResult, $iterator->key()); $this->assertEquals($rowIndexResult, $iterator->key());
for ($i = 1; $i < $columnIndexResult-1; $i++) { for ($i = 1; $i < $rowIndexResult-1; $i++) {
$iterator->prev(); $iterator->prev();
$this->assertEquals($columnIndexResult - $i, $iterator->key()); $this->assertEquals($rowIndexResult - $i, $iterator->key());
} }
} }
/**
* @expectedException PHPExcel_Exception
*/
public function testStartOutOfRange()
{
$iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 256, 512);
}
/** /**
* @expectedException PHPExcel_Exception * @expectedException PHPExcel_Exception
*/ */

View File

@ -0,0 +1,6 @@
{12.25;10.5;5.1;8.35;13.45;7.95;6;4.55}, {2013;2012;2012;2013;2013;2011;2013;2009}, "=2013", 40.05
{12.25;10.5;5.1;8.35;13.45;7.95;6;4.55}, {"Oranges";"Bananas";"Apples";"Bananas";"Oranges";"Apples";"Pears";"Oranges"}, "=Oranges", 30.25
{12.25;10.5;5.1;8.35;13.45;7.95;6;4.55}, {2013;2012;2012;2013;2013;2011;2013;2009}, "=2013", {"Oranges";"Bananas";"Apples";"Bananas";"Oranges";"Apples";"Pears";"Oranges"}, "=Oranges", 25.7
{12.25;10.5;5.1;8.35;13.45;7.95;6;4.55}, {2013;2012;2012;2013;2013;2011;2013;2009}, ">=2009", {"Oranges";"Bananas";"Apples";"Bananas";"Oranges";"Apples";"Pears";"Oranges"}, "=Oranges", {2013;2012;2012;2013;2013;2011;2013;2009}, "<=2012", 4.55
{12.25;10.5;5.1;8.35;13.45;7.95;6;4.55}, {2013;2012;2012;2013;2013;2011;2013;2009}, ">=2009", {"Oranges";"Bananas";"Apples";"Bananas";"Oranges";"Apples";"Pears";"Oranges"}, "=B*", 18.85
{12.25;10.5;5.1;8.35;13.45;7.95;6;4.55}, {2013;2012;2012;2013;2013;2011;2013;2009}, ">=2009", {"Oranges";"Bananas";"Apples";"Bananas";"Oranges";"Apples";"Pears";"Oranges"}, "=B?nanas", 18.85