/** * Store the BOTTOMMARGIN BIFF record. */ private function _writeMarginBottom() { $record = 0x29; // Record identifier $length = 0x8; // Bytes to follow $margin = $this->_phpSheet->getPageMargins()->getBottom(); // Margin in inches $header = pack("vv", $record, $length); $data = pack("d", $margin); if (Writer_Excel5_BIFFwriter::getByteOrder()) { // if it's Big Endian $data = strrev($data); } $this->_append($header . $data); }
/** * Read PAGESETUP record */ private function _readPageSetup() { $length = $this->_GetInt2d($this->_data, $this->_pos + 2); $recordData = substr($this->_data, $this->_pos + 4, $length); // move stream pointer to next record $this->_pos += 4 + $length; if (!$this->_readDataOnly) { // offset: 0; size: 2; paper size $paperSize = $this->_GetInt2d($recordData, 0); // offset: 2; size: 2; scaling factor $scale = $this->_GetInt2d($recordData, 2); // offset: 6; size: 2; fit worksheet width to this number of pages, 0 = use as many as needed $fitToWidth = $this->_GetInt2d($recordData, 6); // offset: 8; size: 2; fit worksheet height to this number of pages, 0 = use as many as needed $fitToHeight = $this->_GetInt2d($recordData, 8); // offset: 10; size: 2; option flags // bit: 1; mask: 0x0002; 0=landscape, 1=portrait $isPortrait = (0x2 & $this->_GetInt2d($recordData, 10)) >> 1; // bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init // when this bit is set, do not use flags for those properties $isNotInit = (0x4 & $this->_GetInt2d($recordData, 10)) >> 2; if (!$isNotInit) { $this->_phpSheet->getPageSetup()->setPaperSize($paperSize); switch ($isPortrait) { case 0: $this->_phpSheet->getPageSetup()->setOrientation(Worksheet_PageSetup::ORIENTATION_LANDSCAPE); break; case 1: $this->_phpSheet->getPageSetup()->setOrientation(Worksheet_PageSetup::ORIENTATION_PORTRAIT); break; } $this->_phpSheet->getPageSetup()->setScale($scale, false); $this->_phpSheet->getPageSetup()->setFitToPage((bool) $this->_isFitToPages); $this->_phpSheet->getPageSetup()->setFitToWidth($fitToWidth, false); $this->_phpSheet->getPageSetup()->setFitToHeight($fitToHeight, false); } // offset: 16; size: 8; header margin (IEEE 754 floating-point value) $marginHeader = $this->_extractNumber(substr($recordData, 16, 8)); $this->_phpSheet->getPageMargins()->setHeader($marginHeader); // offset: 24; size: 8; footer margin (IEEE 754 floating-point value) $marginFooter = $this->_extractNumber(substr($recordData, 24, 8)); $this->_phpSheet->getPageMargins()->setFooter($marginFooter); } }
/** * Write PageMargins * * @param Shared_XMLWriter $objWriter XML Writer * @param Worksheet $pSheet Worksheet * @throws Exception */ private function _writePageMargins(Shared_XMLWriter $objWriter = null, Worksheet $pSheet = null) { // pageMargins $objWriter->startElement('pageMargins'); $objWriter->writeAttribute('left', Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft())); $objWriter->writeAttribute('right', Shared_String::FormatNumber($pSheet->getPageMargins()->getRight())); $objWriter->writeAttribute('top', Shared_String::FormatNumber($pSheet->getPageMargins()->getTop())); $objWriter->writeAttribute('bottom', Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom())); $objWriter->writeAttribute('header', Shared_String::FormatNumber($pSheet->getPageMargins()->getHeader())); $objWriter->writeAttribute('footer', Shared_String::FormatNumber($pSheet->getPageMargins()->getFooter())); $objWriter->endElement(); }