Example #1
0
	/**
	 * @param integer $time_1st A timestamp
	 * @param integer $time_2nd A timestamp
	 */
	public function __construct($time_1st, $time_2nd, $raChild)
	{
		$this->_tmp_dir = '';
		parent::__construct(
		   null,
		   PHPExcel_Shared_OLE::Asc2Ucs('Root Entry'),
		   PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT,
		   null,
		   null,
		   null,
		   $time_1st,
		   $time_2nd,
		   null,
		   $raChild);
	}
Example #2
0
                        // FIXME: what if sheetname contains comma?
                        $extractedRanges = array();
                        foreach ($ranges as $range) {
                            // $range should look like one of these
                            //		Foo!$C$7:$J$66
                            //		Bar!$A$1:$IV$2
                            $explodes = explode('!', $range);
                            // FIXME: what if sheetname contains exclamation mark?
                            $sheetName = $explodes[0];
                            if (count($explodes) == 2) {
                                $extractedRanges[] = str_replace('$', '', $explodes[1]);
                                // C7:J66
                            }
                        }
                        if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) {
                            $docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges));
                            // C7:J66,A1:IV2
                        }
                        break;
                    case pack('C', 0x7):
                        // print titles (repeating rows)
                        // Assuming BIFF8, there are 3 cases
                        // 1. repeating rows
                        //		formula looks like this: Sheet!$A$1:$IV$2
                        //		rows 1-2 repeat
                        // 2. repeating columns
                        //		formula looks like this: Sheet!$A$1:$B$65536
                        //		columns A-B repeat
                        // 3. both repeating rows and repeating columns
                        //		formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2
                        $ranges = explode(',', $definedName['formula']);
                        // FIXME: what if sheetname contains comma?
                        foreach ($ranges as $range) {
                            // $range should look like this one of these
                            //		Sheet!$A$1:$B$65536
                            //		Sheet!$A$1:$IV$2
                            $explodes = explode('!', $range);
                            if (count($explodes) == 2) {
                                if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
                                    $extractedRange = $explodes[1];
                                    $extractedRange = str_replace('$', '', $extractedRange);
                                    $coordinateStrings = explode(':', $extractedRange);
                                    if (count($coordinateStrings) == 2) {
                                        list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]);
                                        list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]);
                                        if ($firstColumn == 'A' and $lastColumn == 'IV') {
                                            // then we have repeating rows
                                            $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow));
                                        } elseif ($firstRow == 1 and $lastRow == 65536) {
                                            // then we have repeating columns
                                            $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn));
                                        }
                                    }
                                }
                            }
                        }
                        break;
                }
            } else {
                // Extract range
                $explodes = explode('!', $definedName['formula']);
                if (count($explodes) == 2) {
                    if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) {
                        $extractedRange = $explodes[1];
                        $extractedRange = str_replace('$', '', $extractedRange);
                        $localOnly = $definedName['scope'] == 0 ? false : true;
                        $scope = $definedName['scope'] == 0 ? null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']);
                        $this->_phpExcel->addNamedRange(new PHPExcel_NamedRange((string) $definedName['name'], $docSheet, $extractedRange, $localOnly, $scope));
                    }
                }
            }
        }
        return $this->_phpExcel;
    }
    /**
	 * Use OLE reader to extract the relevant data streams from the OLE file
	 *
	 * @param string $pFilename
	 */
    private function _loadOLE($pFilename)
    {
        // OLE reader
        $ole = new PHPExcel_Shared_OLERead();
        // get excel data,
        $res = $ole->read($pFilename);
        // Get workbook data: workbook stream + sheet streams
        $this->_data = $ole->getStream($ole->wrkbook);
        // Get summary information data
        $this->_summaryInformation = $ole->getStream($ole->summaryInformation);
        // Get additional document summary information data
        $this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation);
        // Get user-defined property data
        //		$this->_userDefinedProperties = $ole->getUserDefinedProperties();
    }
    /**
	 * Read summary information
	 */
    private function _readSummaryInformation()
    {
        if (!isset($this->_summaryInformation)) {
            return;
        }
        // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
        // offset: 2; size: 2;
        // offset: 4; size: 2; OS version
        // offset: 6; size: 2; OS indicator
        // offset: 8; size: 16
        // offset: 24; size: 4; section count
        $secCount = self::_GetInt4d($this->_summaryInformation, 24);
        // offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9
        // offset: 44; size: 4
        $secOffset = self::_GetInt4d($this->_summaryInformation, 44);
        // section header
        // offset: $secOffset; size: 4; section length
        $secLength = self::_GetInt4d($this->_summaryInformation, $secOffset);
        // offset: $secOffset+4; size: 4; property count
        $countProperties = self::_GetInt4d($this->_summaryInformation, $secOffset + 4);
        // initialize code page (used to resolve string values)
        $codePage = 'CP1252';
        // offset: ($secOffset+8); size: var
        // loop through property decarations and properties
        for ($i = 0; $i < $countProperties; ++$i) {
            // offset: ($secOffset+8) + (8 * $i); size: 4; property ID
            $id = self::_GetInt4d($this->_summaryInformation, $secOffset + 8 + 8 * $i);
            // Use value of property id as appropriate
            // offset: ($secOffset+12) + (8 * $i); size: 4; offset from beginning of section (48)
            $offset = self::_GetInt4d($this->_summaryInformation, $secOffset + 12 + 8 * $i);
            $type = self::_GetInt4d($this->_summaryInformation, $secOffset + $offset);
            // initialize property value
            $value = null;
            // extract property value based on property type
            switch ($type) {
                case 0x2:
                    // 2 byte signed integer
                    $value = self::_GetInt2d($this->_summaryInformation, $secOffset + 4 + $offset);
                    break;
                case 0x3:
                    // 4 byte signed integer
                    $value = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset);
                    break;
Example #3
0
 /**
  * Returns a string with the PPS's WK (What is a WK?)
  *
  * @access public
  * @return string The binary string
  */
 public function _getPpsWk()
 {
     $ret = str_pad($this->Name, 64, "");
     $ret .= pack("v", strlen($this->Name) + 2) . pack("c", $this->Type) . pack("c", 0x0) . pack("V", $this->PrevPps) . pack("V", $this->NextPps) . pack("V", $this->DirPps) . "\t" . "" . "À" . "F" . "" . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st) . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd) . pack("V", isset($this->_StartBlock) ? $this->_StartBlock : 0) . pack("V", $this->Size) . pack("V", 0);
     // 128
     return $ret;
 }
Example #4
0
 /**
  * Save PHPExcel to file
  *
  * @param	string		$pFileName
  * @throws	Exception
  */
 public function save($pFilename = null)
 {
     // check mbstring.func_overload
     if (ini_get('mbstring.func_overload') != 0) {
         throw new Exception('Multibyte string function overloading in PHP must be disabled.');
     }
     // garbage collect
     $this->_phpExcel->garbageCollect();
     $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
     PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
     // Initialise workbook writer
     $this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_tempDir);
     // Initialise worksheet writers
     $countSheets = count($this->_phpExcel->getAllSheets());
     for ($i = 0; $i < $countSheets; ++$i) {
         $phpSheet = $this->_phpExcel->getSheet($i);
         $writerWorksheet = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_tempDir, $phpSheet);
         $this->_writerWorksheets[$i] = $writerWorksheet;
     }
     // add 15 identical cell style Xfs
     // for now, we use the first cellXf instead of cellStyleXf
     $cellXfCollection = $this->_phpExcel->getCellXfCollection();
     for ($i = 0; $i < 15; ++$i) {
         $this->_writerWorkbook->addXfWriter($cellXfCollection[0], true);
     }
     // add all the cell Xfs
     foreach ($this->_phpExcel->getCellXfCollection() as $style) {
         $this->_writerWorkbook->addXfWriter($style, false);
     }
     // initialize OLE file
     $workbookStreamName = $this->_BIFF_version == 0x600 ? 'Workbook' : 'Book';
     $OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
     if ($this->_tempDir != '') {
         $OLE->setTempDir($this->_tempDir);
     }
     $res = $OLE->init();
     // Write the worksheet streams before the global workbook stream,
     // because the byte sizes of these are needed in the global workbook stream
     $worksheetSizes = array();
     for ($i = 0; $i < $countSheets; ++$i) {
         $this->_writerWorksheets[$i]->close();
         $worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
     }
     // add binary data for global workbook stream
     $OLE->append($this->_writerWorkbook->writeWorkbook($worksheetSizes));
     // add binary data for sheet streams
     for ($i = 0; $i < $countSheets; ++$i) {
         while (($tmp = $this->_writerWorksheets[$i]->getData()) !== false) {
             $OLE->append($tmp);
         }
     }
     $root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE));
     if ($this->_tempDir != '') {
         $root->setTempDir($this->_tempDir);
     }
     // save the OLE file
     $res = $root->save($pFilename);
     PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
     // clean up
     foreach ($this->_writerWorksheets as $sheet) {
         $sheet->cleanup();
     }
 }
Example #5
0
 /**
  * Read summary information
  */
 private function _readSummaryInformation()
 {
     if (!isset($this->_summaryInformation)) {
         return;
     }
     // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
     // offset: 2; size: 2;
     // offset: 4; size: 2; OS version
     // offset: 6; size: 2; OS indicator
     // offset: 8; size: 16
     // offset: 24; size: 4; section count
     // offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9
     // offset: 44; size: 4
     // section header
     // offset: 48; size: 4; section length
     $secLength = $this->_GetInt4d($this->_summaryInformation, 48);
     // offset: 52; size: 4; property count
     $countProperties = $this->_GetInt4d($this->_summaryInformation, 52);
     // initialize code page (used to resolve string values)
     $codePage = 'CP1252';
     // offset: 56; size: var
     // loop through property decarations and properties
     for ($i = 0; $i < $countProperties; ++$i) {
         // offset: 56 + 8 * $i; size: 4; property ID
         $id = $this->_GetInt4d($this->_summaryInformation, 56 + 8 * $i);
         // offset: 60 + 8 * $i; size: 4; offset from beginning of section (48)
         $offset = $this->_GetInt4d($this->_summaryInformation, 60 + 8 * $i);
         $type = $this->_GetInt4d($this->_summaryInformation, 48 + $offset);
         // initialize property value
         $value = null;
         // extract property value based on property type
         switch ($type) {
             case 0x2:
                 // 2 byte signed integer
                 $value = $this->_GetInt2d($this->_summaryInformation, 52 + $offset);
                 break;
             case 0x3:
                 // 4 byte signed integer
                 $value = $this->_GetInt4d($this->_summaryInformation, 52 + $offset);
                 break;
             case 0x13:
                 // 4 byte unsigned integer
                 // not needed yet, fix later if necessary
                 break;
             case 0x1e:
                 // null-terminated string prepended by dword string length
                 $byteLength = $this->_GetInt4d($this->_summaryInformation, 52 + $offset);
                 $value = substr($this->_summaryInformation, 56 + $offset, $byteLength);
                 $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage);
                 $value = rtrim($value);
                 break;
             case 0x40:
                 // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
                 // PHP-time
                 $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_summaryInformation, 52 + $offset, 8));
                 break;
             case 0x47:
                 // Clipboard format
                 // not needed yet, fix later if necessary
                 break;
         }
         // Use value of property id as appropriate
         switch ($id) {
             case 0x1:
                 // Code Page
                 $codePage = PHPExcel_Shared_CodePage::NumberToName($value);
                 break;
             case 0x2:
                 // Title
                 $this->_phpExcel->getProperties()->setTitle($value);
                 break;
             case 0x3:
                 // Subject
                 $this->_phpExcel->getProperties()->setSubject($value);
                 break;
             case 0x4:
                 // Author (Creator)
                 $this->_phpExcel->getProperties()->setCreator($value);
                 break;
             case 0x5:
                 // Keywords
                 $this->_phpExcel->getProperties()->setKeywords($value);
                 break;
             case 0x6:
                 // Comments (Description)
                 $this->_phpExcel->getProperties()->setDescription($value);
                 break;
             case 0x8:
                 // Last Saved By (LastModifiedBy)
                 $this->_phpExcel->getProperties()->setLastModifiedBy($value);
                 break;
             case 0x9:
                 // Revision
                 // not supported by PHPExcel
                 break;
             case 0xc:
                 // Created
                 $this->_phpExcel->getProperties()->setCreated($value);
                 break;
             case 0xd:
                 // Modified
                 $this->_phpExcel->getProperties()->setModified($value);
                 break;
             case 0x12:
                 // Name of creating application
                 // not supported by PHPExcel
                 break;
         }
     }
 }
Example #6
0
    /**
    * Store the workbook in an OLE container
    *
    * @access private
    * @return mixed true on success
    */
    function _storeOLEFile()
    {
        $OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs('Book'));
        if ($this->_tmp_dir != '') {
            $OLE->setTempDir($this->_tmp_dir);
        }
        $res = $OLE->init();
        $OLE->append($this->_data);

        $total_worksheets = count($this->_worksheets);
        for ($i = 0; $i < $total_worksheets; $i++) {
            while ($tmp = $this->_worksheets[$i]->getData()) {
                $OLE->append($tmp);
            }
        }

        $root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE));
        if ($this->_tmp_dir != '') {
            $root->setTempDir($this->_tmp_dir);
        }

        $res = $root->save($this->_filename);
        return true;
    }
 /**
  * Build the OLE Part for Summary Information
  *
  * @return string
  */
 private function _writeSummaryInformation()
 {
     // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
     $data = pack('v', 0xfffe);
     // offset: 2; size: 2;
     $data .= pack('v', 0x0);
     // offset: 4; size: 2; OS version
     $data .= pack('v', 0x106);
     // offset: 6; size: 2; OS indicator
     $data .= pack('v', 0x2);
     // offset: 8; size: 16
     $data .= pack('VVVV', 0x0, 0x0, 0x0, 0x0);
     // offset: 24; size: 4; section count
     $data .= pack('V', 0x1);
     // offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9
     $data .= pack('vvvvvvvv', 0x85e0, 0xf29f, 0x4ff9, 0x1068, 0x91ab, 0x8, 0x272b, 0xd9b3);
     // offset: 44; size: 4; offset of the start
     $data .= pack('V', 0x30);
     // SECTION
     $dataSection = array();
     $dataSection_NumProps = 0;
     $dataSection_Summary = '';
     $dataSection_Content = '';
     // CodePage : CP-1252
     $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x1), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x2), 'data' => array('data' => 1252));
     $dataSection_NumProps++;
     //	Title
     if ($this->_phpExcel->getProperties()->getTitle()) {
         $dataProp = $this->_phpExcel->getProperties()->getTitle();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x2), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1e), 'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
         $dataSection_NumProps++;
     }
     //	Subject
     if ($this->_phpExcel->getProperties()->getSubject()) {
         $dataProp = $this->_phpExcel->getProperties()->getSubject();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x3), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1e), 'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
         $dataSection_NumProps++;
     }
     //	Author (Creator)
     if ($this->_phpExcel->getProperties()->getCreator()) {
         $dataProp = $this->_phpExcel->getProperties()->getCreator();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x4), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1e), 'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
         $dataSection_NumProps++;
     }
     //	Keywords
     if ($this->_phpExcel->getProperties()->getKeywords()) {
         $dataProp = $this->_phpExcel->getProperties()->getKeywords();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x5), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1e), 'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
         $dataSection_NumProps++;
     }
     //	Comments (Description)
     if ($this->_phpExcel->getProperties()->getDescription()) {
         $dataProp = $this->_phpExcel->getProperties()->getDescription();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x6), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1e), 'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
         $dataSection_NumProps++;
     }
     //	Last Saved By (LastModifiedBy)
     if ($this->_phpExcel->getProperties()->getLastModifiedBy()) {
         $dataProp = $this->_phpExcel->getProperties()->getLastModifiedBy();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x8), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x1e), 'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
         $dataSection_NumProps++;
     }
     //	Created Date/Time
     if ($this->_phpExcel->getProperties()->getCreated()) {
         $dataProp = $this->_phpExcel->getProperties()->getCreated();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0xc), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x40), 'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp)));
         $dataSection_NumProps++;
     }
     //	Modified Date/Time
     if ($this->_phpExcel->getProperties()->getModified()) {
         $dataProp = $this->_phpExcel->getProperties()->getModified();
         $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0xd), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x40), 'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp)));
         $dataSection_NumProps++;
     }
     //	Security
     $dataSection[] = array('summary' => array('pack' => 'V', 'data' => 0x13), 'offset' => array('pack' => 'V'), 'type' => array('pack' => 'V', 'data' => 0x3), 'data' => array('data' => 0x0));
     $dataSection_NumProps++;
     // 		4 	Section Length
     //		4 	Property count
     //		8 * $dataSection_NumProps (8 =  ID (4) + OffSet(4))
     $dataSection_Content_Offset = 8 + $dataSection_NumProps * 8;
     foreach ($dataSection as $dataProp) {
         // Summary
         $dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']);
         // Offset
         $dataSection_Summary .= pack($dataProp['offset']['pack'], $dataSection_Content_Offset);
         // DataType
         $dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']);
         // Data
         if ($dataProp['type']['data'] == 0x2) {
             // 2 byte signed integer
             $dataSection_Content .= pack('V', $dataProp['data']['data']);
             $dataSection_Content_Offset += 4 + 4;
         } elseif ($dataProp['type']['data'] == 0x3) {
             // 4 byte signed integer
             $dataSection_Content .= pack('V', $dataProp['data']['data']);
             $dataSection_Content_Offset += 4 + 4;
         } elseif ($dataProp['type']['data'] == 0x1e) {
             // null-terminated string prepended by dword string length
             // Null-terminated string
             $dataProp['data']['data'] .= chr(0);
             $dataProp['data']['length'] += 1;
             // Complete the string with null string for being a %4
             $dataProp['data']['length'] = $dataProp['data']['length'] + (4 - $dataProp['data']['length'] % 4 == 4 ? 0 : 4 - $dataProp['data']['length'] % 4);
             $dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT);
             $dataSection_Content .= pack('V', $dataProp['data']['length']);
             $dataSection_Content .= $dataProp['data']['data'];
             $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
         } elseif ($dataProp['type']['data'] == 0x40) {
             // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
             $dataSection_Content .= $dataProp['data']['data'];
             $dataSection_Content_Offset += 4 + 8;
         } else {
             // Data Type Not Used at the moment
         }
     }
     // Now $dataSection_Content_Offset contains the size of the content
     // section header
     // offset: $secOffset; size: 4; section length
     // 		+ x  Size of the content (summary + content)
     $data .= pack('V', $dataSection_Content_Offset);
     // offset: $secOffset+4; size: 4; property count
     $data .= pack('V', $dataSection_NumProps);
     // Section Summary
     $data .= $dataSection_Summary;
     // Section Content
     $data .= $dataSection_Content;
     return $data;
 }
Example #8
0
 /**
  * Save PHPExcel to file
  *
  * @param	string		$pFileName
  * @throws	Exception
  */
 public function save($pFilename = null)
 {
     // garbage collect
     $this->_phpExcel->garbageCollect();
     $saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
     PHPExcel_Calculation::getInstance()->writeDebugLog = false;
     $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
     PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
     // initialize colors array
     $this->_colors = array();
     // Initialise workbook writer
     $this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
     // Initialise worksheet writers
     $countSheets = $this->_phpExcel->getSheetCount();
     for ($i = 0; $i < $countSheets; ++$i) {
         $this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_preCalculateFormulas, $this->_phpExcel->getSheet($i));
     }
     // build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.
     $this->_buildWorksheetEschers();
     $this->_buildWorkbookEscher();
     // add 15 identical cell style Xfs
     // for now, we use the first cellXf instead of cellStyleXf
     $cellXfCollection = $this->_phpExcel->getCellXfCollection();
     for ($i = 0; $i < 15; ++$i) {
         $this->_writerWorkbook->addXfWriter($cellXfCollection[0], true);
     }
     // add all the cell Xfs
     foreach ($this->_phpExcel->getCellXfCollection() as $style) {
         $this->_writerWorkbook->addXfWriter($style, false);
     }
     // initialize OLE file
     $workbookStreamName = $this->_BIFF_version == 0x600 ? 'Workbook' : 'Book';
     $OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
     // Write the worksheet streams before the global workbook stream,
     // because the byte sizes of these are needed in the global workbook stream
     $worksheetSizes = array();
     for ($i = 0; $i < $countSheets; ++$i) {
         $this->_writerWorksheets[$i]->close();
         $worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
     }
     // add binary data for global workbook stream
     $OLE->append($this->_writerWorkbook->writeWorkbook($worksheetSizes));
     // add binary data for sheet streams
     for ($i = 0; $i < $countSheets; ++$i) {
         $OLE->append($this->_writerWorksheets[$i]->getData());
     }
     $root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE));
     // save the OLE file
     $res = $root->save($pFilename);
     PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
     PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
 }
Example #9
0
	/**
	* Returns a string with the PPS's WK (What is a WK?)
	*
	* @access public
	* @return string The binary string
	*/
	public function _getPpsWk()
	{
		$ret = str_pad($this->Name,64,"\x00");

		$ret .= pack("v", strlen($this->Name) + 2)  // 66
			  . pack("c", $this->Type)              // 67
			  . pack("c", 0x00) //UK                // 68
			  . pack("V", $this->PrevPps) //Prev    // 72
			  . pack("V", $this->NextPps) //Next    // 76
			  . pack("V", $this->DirPps)  //Dir     // 80
			  . "\x00\x09\x02\x00"                  // 84
			  . "\x00\x00\x00\x00"                  // 88
			  . "\xc0\x00\x00\x00"                  // 92
			  . "\x00\x00\x00\x46"                  // 96 // Seems to be ok only for Root
			  . "\x00\x00\x00\x00"                  // 100
			  . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st)       // 108
			  . PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd)       // 116
			  . pack("V", isset($this->_StartBlock)?
						$this->_StartBlock:0)        // 120
			  . pack("V", $this->Size)               // 124
			  . pack("V", 0);                        // 128
		return $ret;
	}
Example #10
0
	/**
	 * Returns a string with the PPS's WK (What is a WK?)
	 *
	 * @access public
	 * @return string The binary string
	 */
	public function _getPpsWk() {
		$ret = str_pad ( $this->Name, 64, "\x00" );
		
		$ret .= pack ( "v", strlen ( $this->Name ) + 2 ) . 		// 66
		pack ( "c", $this->Type ) . 		// 67
		pack ( "c", 0x00 ) . 		// UK // 68
		pack ( "V", $this->PrevPps ) . 		// Prev // 72
		pack ( "V", $this->NextPps ) . 		// Next // 76
		pack ( "V", $this->DirPps ) . 		// Dir // 80
		"\x00\x09\x02\x00" . 		// 84
		"\x00\x00\x00\x00" . 		// 88
		"\xc0\x00\x00\x00" . 		// 92
		"\x00\x00\x00\x46" . 		// 96 // Seems to be ok only for Root
		"\x00\x00\x00\x00" . 		// 100
		PHPExcel_Shared_OLE::LocalDate2OLE ( $this->Time1st ) . 		// 108
		PHPExcel_Shared_OLE::LocalDate2OLE ( $this->Time2nd ) . 		// 116
		pack ( "V", isset ( $this->_StartBlock ) ? $this->_StartBlock : 0 ) . 		// 120
		pack ( "V", $this->Size ) . 		// 124
		pack ( "V", 0 ); // 128
		return $ret;
	}