mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 13:26:07 +03:00
Bugfix: Work item GH321, GH158, CP17824 - LibreOffice created XLSX files results in an empty file.
Bugfix: Work item CP20760 - Formula references to cell on another sheet in ODS files
This commit is contained in:
parent
2caeb22122
commit
e892215970
@ -242,7 +242,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
|
|
||||||
|
|
||||||
private static function _castToBool($c) {
|
private static function _castToBool($c) {
|
||||||
// echo 'Initial Cast to Boolean<br />';
|
// echo 'Initial Cast to Boolean', PHP_EOL;
|
||||||
$value = isset($c->v) ? (string) $c->v : NULL;
|
$value = isset($c->v) ? (string) $c->v : NULL;
|
||||||
if ($value == '0') {
|
if ($value == '0') {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -256,46 +256,46 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
|
|
||||||
|
|
||||||
private static function _castToError($c) {
|
private static function _castToError($c) {
|
||||||
// echo 'Initial Cast to Error<br />';
|
// echo 'Initial Cast to Error', PHP_EOL;
|
||||||
return isset($c->v) ? (string) $c->v : NULL;
|
return isset($c->v) ? (string) $c->v : NULL;
|
||||||
} // function _castToError()
|
} // function _castToError()
|
||||||
|
|
||||||
|
|
||||||
private static function _castToString($c) {
|
private static function _castToString($c) {
|
||||||
// echo 'Initial Cast to String<br />';
|
// echo 'Initial Cast to String, PHP_EOL;
|
||||||
return isset($c->v) ? (string) $c->v : NULL;
|
return isset($c->v) ? (string) $c->v : NULL;
|
||||||
} // function _castToString()
|
} // function _castToString()
|
||||||
|
|
||||||
|
|
||||||
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
|
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
|
||||||
// echo 'Formula',PHP_EOL;
|
// echo 'Formula', PHP_EOL;
|
||||||
// echo '$c->f is '.$c->f.PHP_EOL;
|
// echo '$c->f is ', $c->f, PHP_EOL;
|
||||||
$cellDataType = 'f';
|
$cellDataType = 'f';
|
||||||
$value = "={$c->f}";
|
$value = "={$c->f}";
|
||||||
$calculatedValue = self::$castBaseType($c);
|
$calculatedValue = self::$castBaseType($c);
|
||||||
|
|
||||||
// Shared formula?
|
// Shared formula?
|
||||||
if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') {
|
if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') {
|
||||||
// echo 'SHARED FORMULA'.PHP_EOL;
|
// echo 'SHARED FORMULA', PHP_EOL;
|
||||||
$instance = (string)$c->f['si'];
|
$instance = (string)$c->f['si'];
|
||||||
|
|
||||||
// echo 'Instance ID = '.$instance.PHP_EOL;
|
// echo 'Instance ID = ', $instance, PHP_EOL;
|
||||||
//
|
//
|
||||||
// echo 'Shared Formula Array:'.PHP_EOL;
|
// echo 'Shared Formula Array:', PHP_EOL;
|
||||||
// print_r($sharedFormulas);
|
// print_r($sharedFormulas);
|
||||||
if (!isset($sharedFormulas[(string)$c->f['si']])) {
|
if (!isset($sharedFormulas[(string)$c->f['si']])) {
|
||||||
// echo 'SETTING NEW SHARED FORMULA'.PHP_EOL;
|
// echo 'SETTING NEW SHARED FORMULA', PHP_EOL;
|
||||||
// echo 'Master is '.$r.PHP_EOL;
|
// echo 'Master is ', $r, PHP_EOL;
|
||||||
// echo 'Formula is '.$value.PHP_EOL;
|
// echo 'Formula is ', $value, PHP_EOL;
|
||||||
$sharedFormulas[$instance] = array( 'master' => $r,
|
$sharedFormulas[$instance] = array( 'master' => $r,
|
||||||
'formula' => $value
|
'formula' => $value
|
||||||
);
|
);
|
||||||
// echo 'New Shared Formula Array:'.PHP_EOL;
|
// echo 'New Shared Formula Array:', PHP_EOL;
|
||||||
// print_r($sharedFormulas);
|
// print_r($sharedFormulas);
|
||||||
} else {
|
} else {
|
||||||
// echo 'GETTING SHARED FORMULA'.PHP_EOL;
|
// echo 'GETTING SHARED FORMULA', PHP_EOL;
|
||||||
// echo 'Master is '.$sharedFormulas[$instance]['master'].PHP_EOL;
|
// echo 'Master is ', $sharedFormulas[$instance]['master'], PHP_EOL;
|
||||||
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].PHP_EOL;
|
// echo 'Formula is ', $sharedFormulas[$instance]['formula'], PHP_EOL;
|
||||||
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
|
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
|
||||||
$current = PHPExcel_Cell::coordinateFromString($r);
|
$current = PHPExcel_Cell::coordinateFromString($r);
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$difference[0],
|
$difference[0],
|
||||||
$difference[1]
|
$difference[1]
|
||||||
);
|
);
|
||||||
// echo 'Adjusted Formula is '.$value.PHP_EOL;
|
// echo 'Adjusted Formula is ', $value, PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -770,6 +770,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
//$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE);
|
//$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE);
|
||||||
}
|
}
|
||||||
if (self::boolean($col["hidden"])) {
|
if (self::boolean($col["hidden"])) {
|
||||||
|
echo PHPExcel_Cell::stringFromColumnIndex($i),': HIDDEN COLUMN',PHP_EOL;
|
||||||
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE);
|
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE);
|
||||||
}
|
}
|
||||||
if (self::boolean($col["collapsed"])) {
|
if (self::boolean($col["collapsed"])) {
|
||||||
@ -837,15 +838,15 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// echo '<b>Reading cell '.$coordinates[0].$coordinates[1].'</b><br />';
|
// echo 'Reading cell ', $coordinates[0], $coordinates[1], PHP_EOL;
|
||||||
// print_r($c);
|
// print_r($c);
|
||||||
// echo '<br />';
|
// echo PHP_EOL;
|
||||||
// echo 'Cell Data Type is '.$cellDataType.': ';
|
// echo 'Cell Data Type is ', $cellDataType, ': ';
|
||||||
//
|
//
|
||||||
// Read cell!
|
// Read cell!
|
||||||
switch ($cellDataType) {
|
switch ($cellDataType) {
|
||||||
case "s":
|
case "s":
|
||||||
// echo 'String<br />';
|
// echo 'String', PHP_EOL;
|
||||||
if ((string)$c->v != '') {
|
if ((string)$c->v != '') {
|
||||||
$value = $sharedStrings[intval($c->v)];
|
$value = $sharedStrings[intval($c->v)];
|
||||||
|
|
||||||
@ -858,7 +859,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case "b":
|
case "b":
|
||||||
// echo 'Boolean<br />';
|
// echo 'Boolean', PHP_EOL;
|
||||||
if (!isset($c->f)) {
|
if (!isset($c->f)) {
|
||||||
$value = self::_castToBool($c);
|
$value = self::_castToBool($c);
|
||||||
} else {
|
} else {
|
||||||
@ -869,41 +870,41 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$att = $c->f;
|
$att = $c->f;
|
||||||
$docSheet->getCell($r)->setFormulaAttributes($att);
|
$docSheet->getCell($r)->setFormulaAttributes($att);
|
||||||
}
|
}
|
||||||
// echo '$calculatedValue = '.$calculatedValue.'<br />';
|
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "inlineStr":
|
case "inlineStr":
|
||||||
// echo 'Inline String<br />';
|
// echo 'Inline String', PHP_EOL;
|
||||||
$value = $this->_parseRichText($c->is);
|
$value = $this->_parseRichText($c->is);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "e":
|
case "e":
|
||||||
// echo 'Error<br />';
|
// echo 'Error', PHP_EOL;
|
||||||
if (!isset($c->f)) {
|
if (!isset($c->f)) {
|
||||||
$value = self::_castToError($c);
|
$value = self::_castToError($c);
|
||||||
} else {
|
} else {
|
||||||
// Formula
|
// Formula
|
||||||
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError');
|
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError');
|
||||||
// echo '$calculatedValue = '.$calculatedValue.'<br />';
|
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// echo 'Default<br />';
|
// echo 'Default', PHP_EOL;
|
||||||
if (!isset($c->f)) {
|
if (!isset($c->f)) {
|
||||||
// echo 'Not a Formula<br />';
|
// echo 'Not a Formula', PHP_EOL;
|
||||||
$value = self::_castToString($c);
|
$value = self::_castToString($c);
|
||||||
} else {
|
} else {
|
||||||
// echo 'Treat as Formula<br />';
|
// echo 'Treat as Formula', PHP_EOL;
|
||||||
// Formula
|
// Formula
|
||||||
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString');
|
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString');
|
||||||
// echo '$calculatedValue = '.$calculatedValue.'<br />';
|
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// echo 'Value is '.$value.'<br />';
|
// echo 'Value is ', $value, PHP_EOL;
|
||||||
|
|
||||||
// Check for numeric values
|
// Check for numeric values
|
||||||
if (is_numeric($value) && $cellDataType != 's') {
|
if (is_numeric($value) && $cellDataType != 's') {
|
||||||
@ -2057,9 +2058,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
|
|
||||||
private static function boolean($value = NULL)
|
private static function boolean($value = NULL)
|
||||||
{
|
{
|
||||||
if (is_numeric($value) || is_object($value)) {
|
if (is_object($value)) {
|
||||||
|
$value = (string) $value;
|
||||||
|
}
|
||||||
|
if (is_numeric($value)) {
|
||||||
return (bool) $value;
|
return (bool) $value;
|
||||||
}
|
}
|
||||||
return ($value === 'true' || $value === 'TRUE') ? TRUE : FALSE;
|
return ($value === 'true' || $value === 'TRUE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -624,9 +624,10 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
|
|||||||
foreach($temp as &$value) {
|
foreach($temp as &$value) {
|
||||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||||
if ($tKey = !$tKey) {
|
if ($tKey = !$tKey) {
|
||||||
$value = preg_replace('/\[(.+)\.(.*)\]/Ui','$1!$2',$value); // Cell reference in another sheet
|
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3',$value); // Cell range reference in another sheet
|
||||||
$value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value); // Cell range reference
|
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2',$value); // Cell reference in another sheet
|
||||||
$value = preg_replace('/\[\.(.*)\]/Ui','$1',$value); // Simple cell reference
|
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2',$value); // Cell range reference
|
||||||
|
$value = preg_replace('/\[\.([^\.]+)\]/Ui','$1',$value); // Simple cell reference
|
||||||
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces);
|
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,11 @@ date_default_timezone_set('Europe/London');
|
|||||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
|
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
|
||||||
|
|
||||||
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite;
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite;
|
||||||
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
|
if (PHPExcel_Settings::setCacheStorageMethod($cacheMethod)) {
|
||||||
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||||
|
} else {
|
||||||
|
echo date('H:i:s') , " Unable to set Cell Caching using " , $cacheMethod , " method, reverting to memory" , EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// Create new PHPExcel object
|
||||||
|
@ -38,8 +38,11 @@ date_default_timezone_set('Europe/London');
|
|||||||
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
|
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
|
||||||
|
|
||||||
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3;
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3;
|
||||||
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
|
if (PHPExcel_Settings::setCacheStorageMethod($cacheMethod)) {
|
||||||
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||||
|
} else {
|
||||||
|
echo date('H:i:s') , " Unable to set Cell Caching using " , $cacheMethod , " method, reverting to memory" , EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// Create new PHPExcel object
|
||||||
|
@ -43,6 +43,8 @@ $aTests = array(
|
|||||||
, '05featuredemo.php'
|
, '05featuredemo.php'
|
||||||
, '06largescale.php'
|
, '06largescale.php'
|
||||||
, '06largescale-with-cellcaching.php'
|
, '06largescale-with-cellcaching.php'
|
||||||
|
, '06largescale-with-cellcaching-sqlite.php'
|
||||||
|
, '06largescale-with-cellcaching-sqlite3.php'
|
||||||
, '06largescale-xls.php'
|
, '06largescale-xls.php'
|
||||||
, '07reader.php'
|
, '07reader.php'
|
||||||
, '07readerPCLZip.php'
|
, '07readerPCLZip.php'
|
||||||
|
@ -49,6 +49,7 @@ Fixed in develop branch for release v1.8.0:
|
|||||||
- Bugfix: (MBaker) Work Item CP20604 - Adding Sheet to Workbook Bug
|
- Bugfix: (MBaker) Work Item CP20604 - Adding Sheet to Workbook Bug
|
||||||
- Bugfix: (MBaker) Work item CP20703 - Calculation engine incorrectly evaluates empty cells as #VALUE
|
- Bugfix: (MBaker) Work item CP20703 - Calculation engine incorrectly evaluates empty cells as #VALUE
|
||||||
- Bugfix: (MBaker) Work item CP20760 - Formula references to cell on another sheet in ODS files
|
- Bugfix: (MBaker) Work item CP20760 - Formula references to cell on another sheet in ODS files
|
||||||
|
- Bugfix: (MBaker) Work item GH321,GH158,CP17824 - LibreOffice created XLSX files results in an empty file.
|
||||||
- Feature: (amerov) - Implementation of the Excel HLOOKUP() function
|
- Feature: (amerov) - Implementation of the Excel HLOOKUP() function
|
||||||
- Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only)
|
- Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only)
|
||||||
- Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer
|
- Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer
|
||||||
|
Loading…
Reference in New Issue
Block a user