Writes Excel BOF record to indicate the beginning of a stream or
sub-stream in the BIFF file.

@param  integer $type Type of BIFF file to write: 0x0005 Workbook,
0x0010 Worksheet.
@access private
196059
function _storeBof($type)
	{
		$record  = 0x0809;			// Record identifier	(BIFF5-BIFF8)
		$length  = 0x0010;

		// by inspection of real files, MS Office Excel 2007 writes the following
		$unknown = pack("VV", 0x000100D1, 0x00000406);

		$build   = 0x0DBB;			//	Excel 97
		$year    = 0x07CC;			//	Excel 97

		$version = 0x0600;			//	BIFF8

		$header  = pack("vv",   $record, $length);
		$data    = pack("vvvv", $version, $type, $build, $year);
		$this->_append($header . $data . $unknown);
	}
1241619
private function _saveBBox($file)
    {
        $this->_saveBBoxRecord($file, 'xmin');
        $this->_saveBBoxRecord($file, 'ymin');
        $this->_saveBBoxRecord($file, 'xmax');
        $this->_saveBBoxRecord($file, 'ymax');
        $this->_saveBBoxRecord($file, 'zmin');
        $this->_saveBBoxRecord($file, 'zmax');
        $this->_saveBBoxRecord($file, 'mmin');
        $this->_saveBBoxRecord($file, 'mmax');
    }
302721
protected function setupAssets($type, $files = [])
    {
        if ($this->$type === self::DUMMY_ASSET) {
            $srcFiles = [];
            $minFiles = [];
            foreach ($files as $file) {
                $srcFiles[] = "{$file}.{$type}";
                $minFiles[] = "{$file}.min.{$type}";
            }

            $this->$type = YII_DEBUG ? $srcFiles : $minFiles;
        } elseif ($this->$type === self::EMPTY_ASSET) {
            $this->$type = [];
        }
    }
213089
public function addFileType($type): self
    {
        $type = '.' . trim($type, '. ');

        if (!isset($this->watchedTypes[$type])) {
            $this->watchedTypes[$type] = true;
        }

        return $this;
    }
264344
public void setType(DBFDataType type) {
		if (!type.isWriteSupported()) {
			throw new IllegalArgumentException("No support for writting " + type);
		}
		this.type = type;
		if (type.getDefaultSize() > 0) {
			this.length = type.getDefaultSize();
		}

	}
1297348
function writeXf()
	{
		// Set the type of the XF record and some of the attributes.
		if ($this->_isStyleXf) {
			$style = 0xFFF5;
		} else {
			$style   = self::_mapLocked($this->_style->getProtection()->getLocked());
			$style  |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1;
		}

		// Flags to indicate if attributes have been set.
		$atr_num     = ($this->_numberFormatIndex != 0)?1:0;
		$atr_fnt     = ($this->_fontIndex != 0)?1:0;
		$atr_alc     = ((int) $this->_style->getAlignment()->getWrapText())?1:0;
		$atr_bdr     = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle())   ||
						self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())      ||
						self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle())     ||
						self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
		$atr_pat     = (($this->_fg_color != 0x40) ||
						($this->_bg_color != 0x41) ||
						self::_mapFillType($this->_style->getFill()->getFillType()))?1:0;
		$atr_prot    = self::_mapLocked($this->_style->getProtection()->getLocked())
						| self::_mapHidden($this->_style->getProtection()->getHidden());

		// Zero the default border colour if the border has not been set.
		if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
			$this->_bottom_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())  == 0) {
			$this->_top_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
			$this->_right_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
			$this->_left_color = 0;
		}
		if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
			$this->_diag_color = 0;
		}

		$record         = 0x00E0;              // Record identifier
		$length         = 0x0014;              // Number of bytes to follow

		$ifnt           = $this->_fontIndex;   // Index to FONT record
		$ifmt           = $this->_numberFormatIndex;  // Index to FORMAT record

		$align          = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal());       // Alignment
		$align         |= (int) $this->_style->getAlignment()->getWrapText()     << 3;
		$align         |= self::_mapVAlign($this->_style->getAlignment()->getVertical())  << 4;
		$align         |= $this->_text_justlast << 7;

		$used_attrib    = $atr_num              << 2;
		$used_attrib   |= $atr_fnt              << 3;
		$used_attrib   |= $atr_alc              << 4;
		$used_attrib   |= $atr_bdr              << 5;
		$used_attrib   |= $atr_pat              << 6;
		$used_attrib   |= $atr_prot             << 7;

		$icv            = $this->_fg_color;      // fg and bg pattern colors
		$icv           |= $this->_bg_color      << 7;

		$border1        = self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle());          // Border line style and color
		$border1       |= self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle())         << 4;
		$border1       |= self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle())           << 8;
		$border1       |= self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle())        << 12;
		$border1       |= $this->_left_color    << 16;
		$border1       |= $this->_right_color   << 23;

		$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
		$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
							|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
		$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
							|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
		$border1       |= $diag_tl_to_rb        << 30;
		$border1       |= $diag_tr_to_lb        << 31;

		$border2        = $this->_top_color;    // Border color
		$border2       |= $this->_bottom_color   << 7;
		$border2       |= $this->_diag_color     << 14;
		$border2       |= self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle())           << 21;
		$border2       |= self::_mapFillType($this->_style->getFill()->getFillType())        << 26;

		$header      = pack("vv",       $record, $length);

		//BIFF8 options: identation, shrinkToFit and  text direction
		$biff8_options  = $this->_style->getAlignment()->getIndent();
		$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;

		$data  = pack("vvvC", $ifnt, $ifmt, $style, $align);
		$data .= pack("CCC"
			, self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
			, $biff8_options
			, $used_attrib
			);
		$data .= pack("VVv", $border1, $border2, $icv);

		return($header . $data);
	}
1268544
public function save($file, $excelWriterType = 'Excel2007')
    {
        if (!$this->phpexcel instanceof \PHPExcel) {
            throw new HtmlPhpExcelException('You must run process() first to create a phpexcel instance');
        }

        $writer = \PHPExcel_IOFactory::createWriter($this->phpexcel, $excelWriterType);
        $writer->save($file);

        return $this;
    }
348477
public void write(EnumType type) throws XMLStreamException {

        LOG.debug("Writing type {} of type {}", type.getName(), type.getMetaType());

        xmlWriter.writeStartElement(ENUM_TYPE);
        xmlWriter.writeAttribute(NAME, type.getName());
        for (EnumMember member : type.getMembers()) {
            xmlWriter.writeStartElement(ENUM_MEMBER);
            xmlWriter.writeAttribute(NAME, member.getName());
            xmlWriter.writeEndElement();
        }
        xmlWriter.writeEndElement();
    }
231112
private function initFieldType($type)
    {
        if (isset($this->fieldTypes[$type])) {
            return;
        }

        $typeInstance = false;
        foreach ($this->extensions as $extension) {
            if ($extension->hasFieldType($type)) {
                $typeInstance = $extension->getFieldType($type);
                break;
            }
        }

        if (!$typeInstance) {
            return;
        }

        $this->fieldTypes[$type] = $typeInstance;

        $ext = [];
        foreach ($this->extensions as $extension) {
            if ($extension->hasFieldTypeExtensions($type)) {
                $fieldExtensions = $extension->getFieldTypeExtensions($type);
                foreach ($fieldExtensions as $fieldExtension) {
                    $ext[] = $fieldExtension;
                }
            }
        }

        $this->fieldExtensions[$type] = $ext;
    }
831401
protected function writeTransform($value, $type)
    {
        if (is_null($value)) {
            return;
        }

        if (is_array($type)) {
            list($type, $param) = $type;
        } elseif (strpos($type, ':')) {
            list($type, $param) = explode(':', $type, 2);
        }

        switch ($type) {
            case 'integer':
                $value = (int) $value;
                break;
            case 'float':
                if (empty($param)) {
                    $value = (float) $value;
                } else {
                    $value = (float) number_format($value, $param, '.', '');
                }
                break;
            case 'boolean':
                $value = (bool) $value;
                break;
            case 'timestamp':
                if (!is_numeric($value)) {
                    $value = strtotime($value);
                }
                break;
            case 'datetime':
                $format = !empty($param) ? $param : $this->dateFormat;
                $value  = is_numeric($value) ? $value : strtotime($value);
                $value  = $this->formatDateTime($format, $value);
                break;
            case 'object':
                if (is_object($value)) {
                    $value = json_encode($value, JSON_FORCE_OBJECT);
                }
                break;
            case 'array':
                $value = (array) $value;
            case 'json':
                $option = !empty($param) ? (int) $param : JSON_UNESCAPED_UNICODE;
                $value  = json_encode($value, $option);
                break;
            case 'serialize':
                $value = serialize($value);
                break;
        }

        return $value;
    }
491046
function write_data(Schema $writers_schema, $datum, IOBinaryEncoder $encoder)
    {
        if (!Schema::is_valid_datum($writers_schema, $datum))
            throw new IOTypeException($writers_schema, $datum);

        switch ($writers_schema->type()) {
            case Schema::NULL_TYPE:
                return $encoder->write_null($datum);
            case Schema::BOOLEAN_TYPE:
                return $encoder->write_boolean($datum);
            case Schema::INT_TYPE:
                return $encoder->write_int($datum);
            case Schema::LONG_TYPE:
                return $encoder->write_long($datum);
            case Schema::FLOAT_TYPE:
                return $encoder->write_float($datum);
            case Schema::DOUBLE_TYPE:
                return $encoder->write_double($datum);
            case Schema::STRING_TYPE:
                return $encoder->write_string($datum);
            case Schema::BYTES_TYPE:
                return $encoder->write_bytes($datum);
            case Schema::ARRAY_SCHEMA:
                return $this->write_array($writers_schema, $datum, $encoder);
            case Schema::MAP_SCHEMA:
                return $this->write_map($writers_schema, $datum, $encoder);
            case Schema::FIXED_SCHEMA:
                return $this->write_fixed($writers_schema, $datum, $encoder);
            case Schema::ENUM_SCHEMA:
                return $this->write_enum($writers_schema, $datum, $encoder);
            case Schema::RECORD_SCHEMA:
            case Schema::ERROR_SCHEMA:
            case Schema::REQUEST_SCHEMA:
                return $this->write_record($writers_schema, $datum, $encoder);
            case Schema::UNION_SCHEMA:
                return $this->write_union($writers_schema, $datum, $encoder);
            default:
                throw new Exception(sprintf('Uknown type: %s',
                    $writers_schema->type));
        }
    }
1242612
public function setFileType (int $fileType)
    {
        if (self::isFileTypeValid($fileType)) $this->fileType = self::$fileTypes[$fileType];
    }
806609
private function _writeRecalcId()
	{
		$record = 0x01C1;    // Record identifier
		$length = 8;         // Number of bytes to follow

		$header = pack('vv',  $record, $length);

		// by inspection of real Excel files, MS Office Excel 2007 writes this
		$data = pack('VV', 0x000001C1, 0x00001E667);

		return $this->writeData($header . $data);
	}
458414
def __write_record(self, record_type, data):
    """"""
    length = len(data)

    crc = crc32c.crc_update(crc32c.CRC_INIT, [record_type])
    crc = crc32c.crc_update(crc, data)
    crc = crc32c.crc_finalize(crc)

    self.__writer.write(
        struct.pack(_HEADER_FORMAT, _mask_crc(crc), length, record_type))
    self.__writer.write(data)
    self.__position += _HEADER_LENGTH + length
104656
function _storeBof($type)
    {
        $record  = 0x0809;        // Record identifier

        // According to the SDK $build and $year should be set to zero.
        // However, this throws a warning in Excel 5. So, use magic numbers.
        if ($this->_BIFF_version == 0x0500) {
            $length  = 0x0008;
            $unknown = '';
            $build   = 0x096C;
            $year    = 0x07C9;
        } elseif ($this->_BIFF_version == 0x0600) {
            $length  = 0x0010;
            $unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
            $build   = 0x0DBB;
            $year    = 0x07CC;
        }
        $version = $this->_BIFF_version;

        $header  = pack("vv",   $record, $length);
        $data    = pack("vvvv", $version, $type, $build, $year);
        $this->_prepend($header . $data . $unknown);
    }
489476
function Spreadsheet_Excel_Writer_Parser($byte_order, $biff_version)
    {
        $this->_current_char  = 0;
        $this->_BIFF_version  = $biff_version;
        $this->_current_token = '';       // The token we are working on.
        $this->_formula       = '';       // The formula to parse.
        $this->_lookahead     = '';       // The character ahead of the current char.
        $this->_parse_tree    = '';       // The parse tree to be generated.
        $this->_initializeHashes();      // Initialize the hashes: ptg's and function's ptg's
        $this->_byte_order = $byte_order; // Little Endian or Big Endian
        $this->_ext_sheets = array();
        $this->_references = array();
    }
492420
public function writeTypedObject($data)
    {
        $this->_stream->writeUTF($this->_className);
        $this->writeObject($data);
        return $this;
    }