Properties

$_data

$_data : string

The string containing the data of the BIFF stream.

Type

string

$_datasize

$_datasize : int

The size of the data in bytes. Should be the same as strlen($this->_data).

Type

int

$byteOrder

$byteOrder : int

The byte order of this architecture. 0 => little endian, 1 => big endian.

Type

int

$limit

$limit : int

The maximum length for a BIFF record (excluding record header and length field). See addContinue().

Type

int

$parser

$parser : \PhpOffice\PhpSpreadsheet\Writer\Xls\Parser

Formula parser.

Type

Parser

$biffSize

$biffSize : int

The BIFF file size for the workbook.

Type

int

$xfWriters

$xfWriters : \PhpOffice\PhpSpreadsheet\Writer\Xls\Xf[]

XF Writers.

Type

Xf[]

$palette

$palette : array

Array containing the colour palette.

Type

array

$codepage

$codepage : int

The codepage indicates the text encoding used for strings.

Type

int

$countryCode

$countryCode : int

The country code used for localization.

Type

int

$spreadsheet

$spreadsheet : \PhpOffice\PhpSpreadsheet\Spreadsheet

Workbook.

Type

Spreadsheet

$fontWriters

$fontWriters : \PhpOffice\PhpSpreadsheet\Writer\Xls\Font[]

Fonts writers.

Type

Font[]

$addedFonts

$addedFonts : array

Added fonts. Maps from font's hash => index in workbook.

Type

array

$numberFormats

$numberFormats : array

Shared number formats.

Type

array

$addedNumberFormats

$addedNumberFormats : array

Added number formats. Maps from numberFormat's hash => index in workbook.

Type

array

$worksheetSizes

$worksheetSizes : array

Sizes of the binary worksheet streams.

Type

array

$worksheetOffsets

$worksheetOffsets : array

Offsets of the binary worksheet streams relative to the start of the global workbook stream.

Type

array

$stringTotal

$stringTotal : int

Total number of shared strings in workbook.

Type

int

$stringUnique

$stringUnique : int

Number of unique shared strings in workbook.

Type

int

$stringTable

$stringTable : array

Array of unique shared strings in workbook.

Type

array

$colors

$colors

Color cache.

$escher

$escher : \PhpOffice\PhpSpreadsheet\Shared\Escher

Escher object corresponding to MSODRAWINGGROUP.

Type

Escher

Methods

__construct()

__construct(\PhpOffice\PhpSpreadsheet\Spreadsheet  $spreadsheet, int  $str_total, int  $str_unique, array  $str_table, array  $colors, \PhpOffice\PhpSpreadsheet\Writer\Xls\Parser  $parser) : mixed

Class constructor.

Parameters

\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet

The Workbook

int $str_total

Total number of strings

int $str_unique

Total number of unique strings

array $str_table

String Table

array $colors

Colour Table

\PhpOffice\PhpSpreadsheet\Writer\Xls\Parser $parser

The formula parser created for the Workbook

Returns

mixed —

getByteOrder()

getByteOrder() : int

Determine the byte order and store it as class data to avoid recalculating it for each call to new().

Returns

int —

writeData()

writeData(string  $data) : string

General storage function like append, but returns string instead of modifying $this->_data.

Parameters

string $data

binary data to write

Returns

string —

writeEof()

writeEof() : mixed

Writes Excel EOF record to indicate the end of a BIFF stream.

Returns

mixed —

addXfWriter()

addXfWriter(\PhpOffice\PhpSpreadsheet\Style\Style  $style, bool  $isStyleXf = false) : int

Add a new XF writer.

Parameters

\PhpOffice\PhpSpreadsheet\Style\Style $style
bool $isStyleXf

Is it a style XF?

Returns

int —

Index to XF record

addFont()

addFont(\PhpOffice\PhpSpreadsheet\Style\Font  $font) : int

Add a font to added fonts.

Parameters

\PhpOffice\PhpSpreadsheet\Style\Font $font

Returns

int —

Index to FONT record

writeWorkbook()

writeWorkbook(array  $pWorksheetSizes) : string

Assemble worksheets into a workbook and send the BIFF data to an OLE storage.

Parameters

array $pWorksheetSizes

The sizes in bytes of the binary worksheet streams

Returns

string —

Binary data for workbook stream

getEscher()

getEscher() : \PhpOffice\PhpSpreadsheet\Shared\Escher

Get Escher object.

Returns

\PhpOffice\PhpSpreadsheet\Shared\Escher —

setEscher()

setEscher(\PhpOffice\PhpSpreadsheet\Shared\Escher  $pValue = null) : void

Set Escher object.

Parameters

\PhpOffice\PhpSpreadsheet\Shared\Escher $pValue

append()

append(string  $data) : void

General storage function.

Parameters

string $data

binary data to append

storeBof()

storeBof(int  $type) : void

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

Parameters

int $type

type of BIFF file to write: 0x0005 Workbook, 0x0010 Worksheet

storeEof()

storeEof() : void

Writes Excel EOF record to indicate the end of a BIFF stream.

addContinue()

addContinue(string  $data) : string

Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In Excel 97 the limit is 8228 bytes. Records that are longer than these limits must be split up into CONTINUE blocks.

This function takes a long BIFF record and inserts CONTINUE records as necessary.

Parameters

string $data

The original binary data to be written

Returns

string —

A very convenient string of continue blocks

addColor()

addColor(string  $rgb) : int

Alter color palette adding a custom color.

Parameters

string $rgb

E.g. 'FF00AA'

Returns

int —

Color index

setPaletteXl97()

setPaletteXl97() : void

Sets the colour palette to the Excel 97+ default.

calcSheetOffsets()

calcSheetOffsets() : void

Calculate offsets for Worksheet BOF records.

writeAllFonts()

writeAllFonts() : void

Store the Excel FONT records.

writeAllNumberFormats()

writeAllNumberFormats() : void

Store user defined numerical formats i.e. FORMAT records.

writeAllXfs()

writeAllXfs() : void

Write all XF records.

writeAllStyles()

writeAllStyles() : void

Write all STYLE records.

parseDefinedNameValue()

parseDefinedNameValue(\PhpOffice\PhpSpreadsheet\DefinedName  $pDefinedName) : string

Parameters

\PhpOffice\PhpSpreadsheet\DefinedName $pDefinedName

Returns

string —

writeAllDefinedNamesBiff8()

writeAllDefinedNamesBiff8() : mixed

Writes all the DEFINEDNAME records (BIFF8).

So far this is only used for repeating rows/columns (print titles) and print areas.

Returns

mixed —

writeDefinedNameBiff8()

writeDefinedNameBiff8(string  $name, string  $formulaData, int  $sheetIndex, bool  $isBuiltIn = false) : string

Write a DEFINEDNAME record for BIFF8 using explicit binary formula data.

Parameters

string $name

The name in UTF-8

string $formulaData

The binary formula data

int $sheetIndex

1-based sheet index the defined name applies to. 0 = global

bool $isBuiltIn

Built-in name?

Returns

string —

Complete binary record data

writeShortNameBiff8()

writeShortNameBiff8(string  $name, string  $sheetIndex, int[][]  $rangeBounds, bool  $isHidden = false) : string

Write a short NAME record.

Parameters

string $name
string $sheetIndex

1-based sheet index the defined name applies to. 0 = global

int[][] $rangeBounds

range boundaries

bool $isHidden

Returns

string —

Complete binary record data

writeCodepage()

writeCodepage() : void

Stores the CODEPAGE biff record.

writeWindow1()

writeWindow1() : void

Write Excel BIFF WINDOW1 record.

writeBoundSheet()

writeBoundSheet(\PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet  $sheet, int  $offset) : void

Writes Excel BIFF BOUNDSHEET record.

Parameters

\PhpOffice\PhpSpreadsheet\Writer\Xls\Worksheet $sheet

Worksheet name

int $offset

Location of worksheet BOF

writeSupbookInternal()

writeSupbookInternal() : mixed

Write Internal SUPBOOK record.

Returns

mixed —

writeExternalsheetBiff8()

writeExternalsheetBiff8() : mixed

Writes the Excel BIFF EXTERNSHEET record. These references are used by formulas.

Returns

mixed —

writeStyle()

writeStyle() : void

Write Excel BIFF STYLE records.

writeNumberFormat()

writeNumberFormat(string  $format, int  $ifmt) : void

Writes Excel FORMAT record for non "built-in" numerical formats.

Parameters

string $format

Custom format string

int $ifmt

Format index code

writeDateMode()

writeDateMode() : void

Write DATEMODE record to indicate the date system in use (1904 or 1900).

writeCountry()

writeCountry() : string

Stores the COUNTRY record for localization.

Returns

string —

writeRecalcId()

writeRecalcId() : string

Write the RECALCID record.

Returns

string —

writePalette()

writePalette() : void

Stores the PALETTE biff record.

writeSharedStringsTable()

writeSharedStringsTable() : string

Handling of the SST continue blocks is complicated by the need to include an additional continuation byte depending on whether the string is split between blocks or whether it starts at the beginning of the block. (There are also additional complications that will arise later when/if Rich Strings are supported).

The Excel documentation says that the SST record should be followed by an EXTSST record. The EXTSST record is a hash table that is used to optimise access to SST. However, despite the documentation it doesn't seem to be required so we will ignore it.

Returns

string —

Binary data

writeMsoDrawingGroup()

writeMsoDrawingGroup() : mixed

Writes the MSODRAWINGGROUP record if needed. Possibly split using CONTINUE records.

Returns

mixed —