\PHPExcel_Writer_Excel5_Workbook

PHPExcel_Writer_Excel5_Workbook

Copyright (c) 2006 - 2015 PHPExcel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Summary

Methods
Properties
Constants
__construct()
getByteOrder()
writeData()
writeEof()
addXfWriter()
addFont()
writeWorkbook()
getEscher()
setEscher()
$_data
$_datasize
No constants found
append()
storeBof()
storeEof()
No protected properties found
N/A
addContinue()
addColor()
setPaletteXl97()
calcSheetOffsets()
writeAllFonts()
writeAllNumberFormats()
writeAllXfs()
writeAllStyles()
writeExternals()
writeNames()
writeAllDefinedNamesBiff8()
writeDefinedNameBiff8()
writeShortNameBiff8()
writeCodepage()
writeWindow1()
writeBoundSheet()
writeSupbookInternal()
writeExternalsheetBiff8()
writeStyle()
writeNumberFormat()
writeDateMode()
writeExternalCount()
writeExternalSheet()
writeNameShort()
writeNameLong()
writeCountry()
writeRecalcId()
writePalette()
writeSharedStringsTable()
writeMsoDrawingGroup()
$byteOrder
$limit
$parser
$biffSize
$xfWriters
$palette
$codepage
$countryCode
$phpExcel
$fontWriters
$addedFonts
$numberFormats
$addedNumberFormats
$worksheetSizes
$worksheetOffsets
$stringTotal
$stringUnique
$stringTable
$colors
$escher
N/A

Properties

$_data

$_data : string

The string containing the data of the BIFF stream

Type

string

$_datasize

$_datasize : integer

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

Type

integer

$byteOrder

$byteOrder : integer

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

Type

integer

$limit

$limit : integer

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

Type

integer

$biffSize

$biffSize : integer

The BIFF file size for the workbook.

Type

integer

$palette

$palette : array

Array containing the colour palette

Type

array

$codepage

$codepage : integer

The codepage indicates the text encoding used for strings

Type

integer

$countryCode

$countryCode : integer

The country code used for localization

Type

integer

$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

$stringTotal

$stringTotal : integer

Total number of shared strings in workbook

Type

integer

$stringUnique

$stringUnique : integer

Number of unique shared strings in workbook

Type

integer

$stringTable

$stringTable : array

Array of unique shared strings in workbook

Type

array

$colors

$colors : 

Color cache

Type

$escher

$escher : \PHPExcel_Shared_Escher

Escher object corresponding to MSODRAWINGGROUP

Type

\PHPExcel_Shared_Escher

Methods

__construct()

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

Class constructor

Parameters

\PHPExcel $phpExcel

The Workbook

$str_total
$str_unique
$str_table
$colors
mixed $parser

The formula parser created for the Workbook

getByteOrder()

getByteOrder() : integer

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

Returns

integer

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() 

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

addXfWriter()

addXfWriter(  $style,   $isStyleXf = false) : integer

Add a new XF writer

Parameters

$style
$isStyleXf

Returns

integer —

Index to XF record

addFont()

addFont(\PHPExcel_Style_Font  $font) : integer

Add a font to added fonts

Parameters

\PHPExcel_Style_Font $font

Returns

integer —

Index to FONT record

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

setEscher()

setEscher(\PHPExcel_Shared_Escher  $pValue = null) 

Set Escher object

Parameters

\PHPExcel_Shared_Escher $pValue

append()

append(string  $data) 

General storage function

Parameters

string $data

binary data to append

storeBof()

storeBof(integer  $type) 

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

Parameters

integer $type

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

storeEof()

storeEof() 

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) : integer

Alter color palette adding a custom color

Parameters

string $rgb

E.g. 'FF00AA'

Returns

integer —

Color index

setPaletteXl97()

setPaletteXl97() 

Sets the colour palette to the Excel 97+ default.

calcSheetOffsets()

calcSheetOffsets() 

Calculate offsets for Worksheet BOF records.

writeAllFonts()

writeAllFonts() 

Store the Excel FONT records.

writeAllNumberFormats()

writeAllNumberFormats() 

Store user defined numerical formats i.e. FORMAT records

writeAllXfs()

writeAllXfs() 

Write all XF records.

writeAllStyles()

writeAllStyles() 

Write all STYLE records.

writeExternals()

writeExternals() 

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

writeNames()

writeNames() 

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

writeAllDefinedNamesBiff8()

writeAllDefinedNamesBiff8() 

Writes all the DEFINEDNAME records (BIFF8).

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

writeDefinedNameBiff8()

writeDefinedNameBiff8(string  $name, string  $formulaData, string  $sheetIndex, boolean  $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

boolean $isBuiltIn

Built-in name?

Returns

string —

Complete binary record data

writeShortNameBiff8()

writeShortNameBiff8(string  $name, string  $sheetIndex, array<mixed,integer[]>  $rangeBounds, boolean  $isHidden = false) : string

Write a short NAME record

Parameters

string $name
string $sheetIndex

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

array<mixed,integer[]> $rangeBounds

range boundaries

boolean $isHidden

Returns

string —

Complete binary record data

writeCodepage()

writeCodepage() 

Stores the CODEPAGE biff record.

writeWindow1()

writeWindow1() 

Write Excel BIFF WINDOW1 record.

writeBoundSheet()

writeBoundSheet(\PHPExcel_Worksheet  $sheet, integer  $offset) 

Writes Excel BIFF BOUNDSHEET record.

Parameters

\PHPExcel_Worksheet $sheet

Worksheet name

integer $offset

Location of worksheet BOF

writeSupbookInternal()

writeSupbookInternal() 

Write Internal SUPBOOK record

writeExternalsheetBiff8()

writeExternalsheetBiff8() 

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

writeStyle()

writeStyle() 

Write Excel BIFF STYLE records.

writeNumberFormat()

writeNumberFormat(string  $format, integer  $ifmt) 

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

Parameters

string $format

Custom format string

integer $ifmt

Format index code

writeDateMode()

writeDateMode() 

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

writeExternalCount()

writeExternalCount(integer  $cxals) 

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

integer $cxals

Number of external references

writeExternalSheet()

writeExternalSheet(string  $sheetname) 

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

writeNameShort()

writeNameShort(integer  $index, integer  $type, integer  $rowmin, integer  $rowmax, integer  $colmin, integer  $colmax) 

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

Parameters

integer $index

Sheet index

integer $type

Built-in name type

integer $rowmin

Start row

integer $rowmax

End row

integer $colmin

Start colum

integer $colmax

End column

writeNameLong()

writeNameLong(integer  $index, integer  $type, integer  $rowmin, integer  $rowmax, integer  $colmin, integer  $colmax) 

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

integer $index

Sheet index

integer $type

Built-in name type

integer $rowmin

Start row

integer $rowmax

End row

integer $colmin

Start colum

integer $colmax

End column

writeCountry()

writeCountry() : string

Stores the COUNTRY record for localization

Returns

string

writeRecalcId()

writeRecalcId() : string

Write the RECALCID record

Returns

string

writePalette()

writePalette() 

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() 

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