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

$_limit

$_limit : int

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

Type

int

$_biffsize

$_biffsize : int

The BIFF file size for the workbook.

Type

int

$_palette

$_palette : array

Array containing the colour palette

Type

array

$_codepage

$_codepage : int

The codepage indicates the text encoding used for strings

Type

int

$_country_code

$_country_code : int

The country code used for localization

Type

int

$_byte_order

$_byte_order : int

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

Type

int

$_phpExcel

$_phpExcel : \PHPExcel

Workbook

Type

PHPExcel

$_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

$_str_total

$_str_total : int

Total number of shared strings in workbook

Type

int

$_str_unique

$_str_unique : int

Number of unique shared strings in workbook

Type

int

$_str_table

$_str_table : array

Array of unique shared strings in workbook

Type

array

$_colors

$_colors

Color cache

$_escher

$_escher : \PHPExcel_Shared_Escher

Escher object corresponding to MSODRAWINGGROUP

Type

PHPExcel_Shared_Escher

Methods

__construct()

__construct(\PHPExcel  $phpExcel = null, int  $str_total, int  $str_unique, array  $str_table, array  $colors, mixed  $parser) : mixed

Class constructor

Parameters

\PHPExcel $phpExcel

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

mixed $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 —

_append()

_append(string  $data) : mixed

General storage function

Parameters

string $data

binary data to append

Returns

mixed —

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 —

_storeBof()

_storeBof(int  $type) : mixed

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.

Returns

mixed —

_storeEof()

_storeEof() : mixed

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

Returns

mixed —

writeEof()

writeEof() : mixed

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

Returns

mixed —

_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

addXfWriter()

addXfWriter(mixed  $style, mixed  $isStyleXf = false) : int

Add a new XF writer

Parameters

mixed $style
mixed $isStyleXf

Returns

int —

Index to XF record

_addFont()

_addFont(\PHPExcel_Style_Font  $font) : int

Add a font to added fonts

Parameters

\PHPExcel_Style_Font $font

Returns

int —

Index to FONT record

_setPaletteXl97()

_setPaletteXl97() : mixed

Sets the colour palette to the Excel 97+ default.

Returns

mixed —

writeWorkbook()

writeWorkbook(array  $pWorksheetSizes = null) : 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

_calcSheetOffsets()

_calcSheetOffsets() : mixed

Calculate offsets for Worksheet BOF records.

Returns

mixed —

getEscher()

getEscher() : \PHPExcel_Shared_Escher

Get Escher object

Returns

\PHPExcel_Shared_Escher —

setEscher()

setEscher(\PHPExcel_Shared_Escher  $pValue = null) : mixed

Set Escher object

Parameters

\PHPExcel_Shared_Escher $pValue

Returns

mixed —

_addColor()

_addColor(string  $rgb) : int

Alter color palette adding a custom color

Parameters

string $rgb

E.g. 'FF00AA'

Returns

int —

Color index

_writeAllFonts()

_writeAllFonts() : mixed

Store the Excel FONT records.

Returns

mixed —

_writeAllNumFormats()

_writeAllNumFormats() : mixed

Store user defined numerical formats i.e. FORMAT records

Returns

mixed —

_writeAllXfs()

_writeAllXfs() : mixed

Write all XF records.

Returns

mixed —

_writeAllStyles()

_writeAllStyles() : mixed

Write all STYLE records.

Returns

mixed —

_writeExterns()

_writeExterns() : mixed

Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for the NAME records.

Returns

mixed —

_writeNames()

_writeNames() : mixed

Write the NAME record to define the print area and the repeat rows and cols.

Returns

mixed —

_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, string  $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

string $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() : mixed

Stores the CODEPAGE biff record.

Returns

mixed —

_writeWindow1()

_writeWindow1() : mixed

Write Excel BIFF WINDOW1 record.

Returns

mixed —

_writeBoundsheet()

_writeBoundsheet(\PHPExcel_Worksheet  $sheet, int  $offset) : mixed

Writes Excel BIFF BOUNDSHEET record.

Parameters

\PHPExcel_Worksheet $sheet

Worksheet name

int $offset

Location of worksheet BOF

Returns

mixed —

_writeSupbookInternal()

_writeSupbookInternal() : mixed

Write Internal SUPBOOK record

Returns

mixed —

_writeExternsheetBiff8()

_writeExternsheetBiff8() : mixed

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

Returns

mixed —

_writeStyle()

_writeStyle() : mixed

Write Excel BIFF STYLE records.

Returns

mixed —

_writeNumFormat()

_writeNumFormat(string  $format, int  $ifmt) : mixed

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

Parameters

string $format

Custom format string

int $ifmt

Format index code

Returns

mixed —

_writeDatemode()

_writeDatemode() : mixed

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

Returns

mixed —

_writeExterncount()

_writeExterncount(int  $cxals) : mixed

Write BIFF record EXTERNCOUNT to indicate the number of external sheet references in the workbook.

Excel only stores references to external sheets that are used in NAME. The workbook NAME record is required to define the print area and the repeat rows and columns.

A similar method is used in Worksheet.php for a slightly different purpose.

Parameters

int $cxals

Number of external references

Returns

mixed —

_writeExternsheet()

_writeExternsheet(string  $sheetname) : mixed

Writes the Excel BIFF EXTERNSHEET record. These references are used by formulas. NAME record is required to define the print area and the repeat rows and columns.

A similar method is used in Worksheet.php for a slightly different purpose.

Parameters

string $sheetname

Worksheet name

Returns

mixed —

_writeNameShort()

_writeNameShort(int  $index, int  $type, int  $rowmin, int  $rowmax, int  $colmin, int  $colmax) : mixed

Store the NAME record in the short format that is used for storing the print area, repeat rows only and repeat columns only.

Parameters

int $index

Sheet index

int $type

Built-in name type

int $rowmin

Start row

int $rowmax

End row

int $colmin

Start colum

int $colmax

End column

Returns

mixed —

_writeNameLong()

_writeNameLong(int  $index, int  $type, int  $rowmin, int  $rowmax, int  $colmin, int  $colmax) : mixed

Store the NAME record in the long format that is used for storing the repeat rows and columns when both are specified. This shares a lot of code with _writeNameShort() but we use a separate method to keep the code clean.

Code abstraction for reuse can be carried too far, and I should know. ;-)

Parameters

int $index

Sheet index

int $type

Built-in name type

int $rowmin

Start row

int $rowmax

End row

int $colmin

Start colum

int $colmax

End column

Returns

mixed —

_writeCountry()

_writeCountry() : string

Stores the COUNTRY record for localization

Returns

string —

_writeRecalcId()

_writeRecalcId() : string

Write the RECALCID record

Returns

string —

_writePalette()

_writePalette() : mixed

Stores the PALETTE biff record.

Returns

mixed —

_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 —