/** * Determine the byte order and store it as class data to avoid * recalculating it for each call to new(). * * @return int */ public static function getByteOrder() { if (!isset(self::$_byte_order)) { // Check if "pack" gives the required IEEE 64bit float $teststr = pack("d", 1.2345); $number = pack("C8", 0x8d, 0x97, 0x6e, 0x12, 0x83, 0xc0, 0xf3, 0x3f); if ($number == $teststr) { $byte_order = 0; // Little Endian } elseif ($number == strrev($teststr)) { $byte_order = 1; // Big Endian } else { // Give up. I'll fix this in a later version. throw new Exception("Required floating point format " . "not supported on this platform."); } self::$_byte_order = $byte_order; } return self::$_byte_order; }
/** * 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); }
/** * Class constructor * * @param PHPExcel $phpExcel The Workbook * @param int $BIFF_verions BIFF version * @param int $str_total Total number of strings * @param int $str_unique Total number of unique strings * @param array $str_table * @param mixed $parser The formula parser created for the Workbook */ public function __construct(PHPExcel $phpExcel = null, $BIFF_version = 0x600, &$str_total, &$str_unique, &$str_table, &$colors, $parser) { // It needs to call its parent's constructor explicitly parent::__construct(); $this->_parser = $parser; $this->_biffsize = 0; $this->_palette = array(); $this->_codepage = 0x4e4; // FIXME: should change for BIFF8 $this->_country_code = -1; $this->_str_total =& $str_total; $this->_str_unique =& $str_unique; $this->_str_table =& $str_table; $this->_colors =& $colors; $this->_setPaletteXl97(); $this->_phpExcel = $phpExcel; if ($BIFF_version == 0x600) { $this->_BIFF_version = 0x600; // change BIFFwriter limit for CONTINUE records $this->_limit = 8224; $this->_codepage = 0x4b0; } // Add empty sheets and Build color cache $countSheets = $phpExcel->getSheetCount(); for ($i = 0; $i < $countSheets; ++$i) { $phpSheet = $phpExcel->getSheet($i); $this->_parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser // for BIFF8 if ($this->_BIFF_version == 0x600) { $supbook_index = 0x0; $ref = pack('vvv', $supbook_index, $i, $i); $this->_parser->_references[] = $ref; // Register reference with parser } // Sheet tab colors? if ($phpSheet->isTabColorSet()) { $this->_addColor($phpSheet->getTabColor()->getRGB()); } } }