/** * @param integer $time_1st A timestamp * @param integer $time_2nd A timestamp */ public function __construct($time_1st, $time_2nd, $raChild) { parent::__construct(null, Shared_OLE::Asc2Ucs('Root Entry'), Shared_OLE::OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild); }
/** * 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 = 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 = 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 = 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; } } }
/** * Save PHPExcel to file * * @param string $pFileName * @throws Exception */ public function save($pFilename = null) { // garbage collect $this->_phpExcel->garbageCollect(); $saveDateReturnType = Calculation_Functions::getReturnDateType(); Calculation_Functions::setReturnDateType(Calculation_Functions::RETURNDATE_EXCEL); // initialize colors array $this->_colors = array(); // Initialise workbook writer $this->_writerWorkbook = new Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version, $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser); // 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 Shared_OLE_PPS_File(Shared_OLE::Asc2Ucs($workbookStreamName)); // Initialise worksheet writers $countSheets = $this->_phpExcel->getSheetCount(); // 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] = new 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)); $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 Shared_OLE_PPS_Root(time(), time(), array($OLE)); // save the OLE file $res = $root->save($pFilename); Calculation_Functions::setReturnDateType($saveDateReturnType); }