diff --git a/Classes/PHPExcel/Settings.php b/Classes/PHPExcel/Settings.php index 3b5d7629..e157e87c 100644 --- a/Classes/PHPExcel/Settings.php +++ b/Classes/PHPExcel/Settings.php @@ -42,6 +42,13 @@ class PHPExcel_Settings const ZIPARCHIVE = 'ZipArchive'; + /** + * Reference to the class used for Zip file management + * e.g. + * ZipArchive + * + * @var string + */ private static $_zipClass = self::ZIPARCHIVE; diff --git a/Classes/PHPExcel/Shared/ZipArchive.php b/Classes/PHPExcel/Shared/ZipArchive.php index 12d306da..724e771a 100644 --- a/Classes/PHPExcel/Shared/ZipArchive.php +++ b/Classes/PHPExcel/Shared/ZipArchive.php @@ -38,6 +38,11 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PCLZip/pclzip.lib.php'; class PHPExcel_Shared_ZipArchive { + /** constants */ + const OVERWRITE = 'OVERWRITE'; + const CREATE = 'CREATE'; + + /** * Temporary storage directory * diff --git a/Classes/PHPExcel/Writer/Excel2007.php b/Classes/PHPExcel/Writer/Excel2007.php index b44aa7df..477d2db0 100644 --- a/Classes/PHPExcel/Writer/Excel2007.php +++ b/Classes/PHPExcel/Writer/Excel2007.php @@ -224,12 +224,18 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter $zipClass = PHPExcel_Settings::getZipClass(); $objZip = new $zipClass(); + // Retrieve OVERWRITE and CREATE constants from the instantiated zip class + // This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP + $ro = new ReflectionObject($objZip); + $zipOverWrite = $ro->getConstant('OVERWRITE'); + $zipCreate = $ro->getConstant('CREATE'); + if (file_exists($pFilename)) { unlink($pFilename); } // Try opening the ZIP file - if ($objZip->open($pFilename, ZIPARCHIVE::OVERWRITE) !== true) { - if ($objZip->open($pFilename, ZIPARCHIVE::CREATE) !== true) { + if ($objZip->open($pFilename, $zipOverWrite) !== true) { + if ($objZip->open($pFilename, $zipCreate) !== true) { throw new Exception("Could not open " . $pFilename . " for writing."); } } diff --git a/changelog.txt b/changelog.txt index b880fce8..d5b5e694 100644 --- a/changelog.txt +++ b/changelog.txt @@ -25,6 +25,7 @@ Fixed in SVN: - Bugfix: (MBaker) Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer +- Bugfix: (MBaker) Work item 15518 - PCLZip library issue - General: (MBaker) Work item 15405 - Two easy to fix Issues concerning PHPExcel_Token_Stack (l10n/UC) - General: (MBaker) Work item 15461 - Locale file paths not fit for windows