You are here

private function PHPExcel_Writer_OpenDocument::_createZip in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument.php \PHPExcel_Writer_OpenDocument::_createZip()

Create zip object

Parameters

string $pFilename:

Return value

ZipArchive

Throws

PHPExcel_Writer_Exception

1 call to PHPExcel_Writer_OpenDocument::_createZip()
PHPExcel_Writer_OpenDocument::save in vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument.php
Save PHPExcel to file

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/OpenDocument.php, line 148

Class

PHPExcel_Writer_OpenDocument
PHPExcel_Writer_OpenDocument

Code

private function _createZip($pFilename) {

  // Create new ZIP file and open it for writing
  $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, $zipOverWrite) !== true) {
    if ($objZip
      ->open($pFilename, $zipCreate) !== true) {
      throw new PHPExcel_Writer_Exception("Could not open {$pFilename} for writing.");
    }
  }
  return $objZip;
}