\PHPExcel_Writer_Excel5_Worksheet

PHPExcel_Writer_Excel5_Worksheet

Summary

Methods
Properties
Constants
__construct()
getByteOrder()
_append()
writeData()
_storeBof()
_storeEof()
writeEof()
_addContinue()
close()
getData()
printRowColHeaders()
setOutline()
_writeBlank()
_writeUrlRange()
_writeUrlWeb()
_writeUrlInternal()
_writeUrlExternal()
insertBitmap()
_positionImage()
_processBitmapGd()
_processBitmap()
getEscher()
setEscher()
$_data
$_datasize
$_limit
$_xls_strmax
$_colinfo
$_selection
$_active_pane
$_outline_on
$_outline_style
$_outline_below
$_outline_right
$_str_total
$_str_unique
$_str_table
$_phpSheet
$_fntHashIndex
No constants found
No protected methods found
No protected properties found
N/A
_writeBIFF8CellRangeAddressFixed()
_writeNumber()
_writeString()
_writeRichTextString()
_writeLabel()
_writeLabelSst()
_writeNote()
_writeBoolErr()
_writeFormula()
_writeStringRecord()
_writeUrl()
_writeRow()
_writeDimensions()
_writeWindow2()
_writeDefaultRowHeight()
_writeDefcol()
_writeColinfo()
_writeSelection()
_writeMergedCells()
_writeSheetLayout()
_writeSheetProtection()
_writeRangeProtection()
_writeExterncount()
_writeExternsheet()
_writePanes()
_writeSetup()
_writeHeader()
_writeFooter()
_writeHcenter()
_writeVcenter()
_writeMarginLeft()
_writeMarginRight()
_writeMarginTop()
_writeMarginBottom()
_writePrintHeaders()
_writePrintGridlines()
_writeGridset()
_writeAutoFilterInfo()
_writeGuts()
_writeWsbool()
_writeBreaks()
_writeProtect()
_writeScenProtect()
_writeObjectProtect()
_writePassword()
_writeObjPicture()
_writeZoom()
_writeMsoDrawing()
_writeDataValidity()
_mapErrorCode()
_writePageLayoutView()
_writeCFRule()
_writeCFHeader()
$_byte_order
$_parser
$_colors
$_firstRowIndex
$_lastRowIndex
$_firstColumnIndex
$_lastColumnIndex
$_countCellStyleXfs
$_escher
N/A

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

$_xls_strmax

$_xls_strmax : int

Maximum number of characters for a string (LABEL record in BIFF5)

Type

int

$_colinfo

$_colinfo : array

Array containing format information for columns

Type

array

$_selection

$_selection : array

Array containing the selected area for the worksheet

Type

array

$_active_pane

$_active_pane : int

The active pane for the worksheet

Type

int

$_outline_on

$_outline_on : int

Whether to use outline.

Type

int

$_outline_style

$_outline_style : bool

Auto outline styles.

Type

bool

$_outline_below

$_outline_below : bool

Whether to have outline summary below.

Type

bool

$_outline_right

$_outline_right : bool

Whether to have outline summary at the right.

Type

bool

$_str_total

$_str_total : int

Reference to the total number of strings in the workbook

Type

int

$_str_unique

$_str_unique : int

Reference to the number of unique strings in the workbook

Type

int

$_str_table

$_str_table : array

Reference to the array containing all the unique strings in the workbook

Type

array

$_fntHashIndex

$_fntHashIndex : array

Array of font hashes associated to FONT records index

Type

array

$_byte_order

$_byte_order : int

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

Type

int

$_colors

$_colors

Color cache

$_firstRowIndex

$_firstRowIndex : int

Index of first used row (at least 0)

Type

int

$_lastRowIndex

$_lastRowIndex : int

Index of last used row. (no used rows means -1)

Type

int

$_firstColumnIndex

$_firstColumnIndex : int

Index of first used column (at least 0)

Type

int

$_lastColumnIndex

$_lastColumnIndex : int

Index of last used column (no used columns means -1)

Type

int

$_countCellStyleXfs

$_countCellStyleXfs : int

Count cell style Xfs

Type

int

$_escher

$_escher : \PHPExcel_Shared_Escher

Escher object corresponding to MSODRAWING

Type

PHPExcel_Shared_Escher

Methods

__construct()

__construct(int  $str_total, int  $str_unique, array  $str_table, array  $colors, mixed  $parser, bool  $preCalculateFormulas, \PHPExcel_Worksheet  $phpSheet) : mixed

Constructor

Parameters

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

bool $preCalculateFormulas

Flag indicating whether formulas should be calculated or just written

\PHPExcel_Worksheet $phpSheet

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

close()

close() : mixed

Add data to the beginning of the workbook (note the reverse order) and to the end of the workbook.

Returns

mixed —

getData()

getData() : string

Retrieves data from memory in one chunk, or from disk in $buffer sized chunks.

Returns

string —

The data

printRowColHeaders()

printRowColHeaders(int  $print = 1) : mixed

Set the option to print the row and column headers on the printed page.

Parameters

int $print

Whether to print the headers or not. Defaults to 1 (print).

Returns

mixed —

setOutline()

setOutline(bool  $visible = true, bool  $symbols_below = true, bool  $symbols_right = true, bool  $auto_style = false) : mixed

This method sets the properties for outlining and grouping. The defaults correspond to Excel's defaults.

Parameters

bool $visible
bool $symbols_below
bool $symbols_right
bool $auto_style

Returns

mixed —

_writeBlank()

_writeBlank(int  $row, int  $col, mixed  $xfIndex) : mixed

Write a blank cell to the specified row and column (zero indexed).

A blank cell is used to specify formatting without adding a string or a number.

A blank cell without a format serves no purpose. Therefore, we don't write a BLANK record unless a format is specified.

Returns 0 : normal termination (including no format) -1 : insufficient number of arguments -2 : row or column out of range

Parameters

int $row

Zero indexed row

int $col

Zero indexed column

mixed $xfIndex

The XF format index

Returns

mixed —

_writeUrlRange()

_writeUrlRange(int  $row1, int  $col1, int  $row2, int  $col2, string  $url) : int

This is the more general form of _writeUrl(). It allows a hyperlink to be written to a range of cells. This function also decides the type of hyperlink to be written. These are either, Web (http, ftp, mailto), Internal (Sheet1!A1) or external ('c:\temp\foo.xls#Sheet1!A1').

Parameters

int $row1

Start row

int $col1

Start column

int $row2

End row

int $col2

End column

string $url

URL string

Returns

int —

_writeUrlWeb()

_writeUrlWeb(int  $row1, int  $col1, int  $row2, int  $col2, string  $url) : int

Used to write http, ftp and mailto hyperlinks.

The link type ($options) is 0x03 is the same as absolute dir ref without sheet. However it is differentiated by the $unknown2 data stream.

Parameters

int $row1

Start row

int $col1

Start column

int $row2

End row

int $col2

End column

string $url

URL string

Returns

int —

_writeUrlInternal()

_writeUrlInternal(int  $row1, int  $col1, int  $row2, int  $col2, string  $url) : int

Used to write internal reference hyperlinks such as "Sheet1!A1".

Parameters

int $row1

Start row

int $col1

Start column

int $row2

End row

int $col2

End column

string $url

URL string

Returns

int —

_writeUrlExternal()

_writeUrlExternal(int  $row1, int  $col1, int  $row2, int  $col2, string  $url) : int

Write links to external directory names such as 'c:\foo.xls', c:\foo.xls#Sheet1!A1', '../../foo.xls'. and '../../foo.xls#Sheet1!A1'.

Note: Excel writes some relative links with the $dir_long string. We ignore these cases for the sake of simpler code.

Parameters

int $row1

Start row

int $col1

Start column

int $row2

End row

int $col2

End column

string $url

URL string

Returns

int —

insertBitmap()

insertBitmap(int  $row, int  $col, mixed  $bitmap, int  $x, int  $y, float  $scale_x = 1, float  $scale_y = 1) : mixed

Insert a 24bit bitmap image in a worksheet.

Parameters

int $row

The row we are going to insert the bitmap into

int $col

The column we are going to insert the bitmap into

mixed $bitmap

The bitmap filename or GD-image resource

int $x

The horizontal position (offset) of the image inside the cell.

int $y

The vertical position (offset) of the image inside the cell.

float $scale_x

The horizontal scale

float $scale_y

The vertical scale

Returns

mixed —

_positionImage()

_positionImage(int  $col_start, int  $row_start, int  $x1, int  $y1, int  $width, int  $height) : mixed

Calculate the vertices that define the position of the image as required by the OBJ record.

+------------+------------+ | A | B | +-----+------------+------------+ | |(x1,y1) | | | 1 |(A1)._| | | | | | | | | | | | +-----+----| BITMAP |-----+ | | | | | | 2 | |______________. | | | | (B2)| | | | (x2,y2)| +---- +------------+------------+

Example of a bitmap that covers some of the area from cell A1 to cell B2.

Based on the width and height of the bitmap we need to calculate 8 vars: $col_start, $row_start, $col_end, $row_end, $x1, $y1, $x2, $y2. The width and height of the cells are also variable and have to be taken into account. The values of $col_start and $row_start are passed in from the calling function. The values of $col_end and $row_end are calculated by subtracting the width and height of the bitmap from the width and height of the underlying cells. The vertices are expressed as a percentage of the underlying cell width as follows (rhs values are in pixels):

x1 = X / W *1024 y1 = Y / H *256 x2 = (X-1) / W *1024 y2 = (Y-1) / H *256

Where: X is distance from the left side of the underlying cell Y is distance from the top of the underlying cell W is the width of the cell H is the height of the cell The SDK incorrectly states that the height should be expressed as a percentage of 1024.

Parameters

int $col_start

Col containing upper left corner of object

int $row_start

Row containing top left corner of object

int $x1

Distance to left side of object

int $y1

Distance to top of object

int $width

Width of image frame

int $height

Height of image frame

Returns

mixed —

_processBitmapGd()

_processBitmapGd(resource  $image) : array

Convert a GD-image into the internal format.

Parameters

resource $image

The image to process

Returns

array —

Array with data and properties of the bitmap

_processBitmap()

_processBitmap(string  $bitmap) : array

Convert a 24 bit bitmap into the modified internal format used by Windows.

This is described in BITMAPCOREHEADER and BITMAPCOREINFO structures in the MSDN library.

Parameters

string $bitmap

The bitmap to process

Returns

array —

Array with data and properties of the bitmap

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 —

_writeBIFF8CellRangeAddressFixed()

_writeBIFF8CellRangeAddressFixed(string  $range = 'A1') : string

Write a cell range address in BIFF8 always fixed range See section 2.5.14 in OpenOffice.org's Documentation of the Microsoft Excel File Format

Parameters

string $range

E.g. 'A1' or 'A1:B6'

Returns

string —

Binary data

_writeNumber()

_writeNumber(int  $row, int  $col, float  $num, mixed  $xfIndex) : int

Write a double to the specified row and column (zero indexed).

An integer can be written as a double. Excel will display an integer. $format is optional.

Returns 0 : normal termination -2 : row or column out of range

Parameters

int $row

Zero indexed row

int $col

Zero indexed column

float $num

The number to write

mixed $xfIndex

The optional XF format

Returns

int —

_writeString()

_writeString(int  $row, int  $col, string  $str, int  $xfIndex) : mixed

Write a LABELSST record or a LABEL record. Which one depends on BIFF version

Parameters

int $row

Row index (0-based)

int $col

Column index (0-based)

string $str

The string

int $xfIndex

Index to XF record

Returns

mixed —

_writeRichTextString()

_writeRichTextString(int  $row, int  $col, string  $str, mixed  $xfIndex, array  $arrcRun) : mixed

Write a LABELSST record or a LABEL record. Which one depends on BIFF version It differs from _writeString by the writing of rich text strings.

Parameters

int $row

Row index (0-based)

int $col

Column index (0-based)

string $str

The string

mixed $xfIndex

The XF format index for the cell

array $arrcRun

Index to Font record and characters beginning

Returns

mixed —

_writeLabel()

_writeLabel(int  $row, int  $col, string  $str, mixed  $xfIndex) : int

Write a string to the specified row and column (zero indexed).

NOTE: there is an Excel 5 defined limit of 255 characters. $format is optional. Returns 0 : normal termination -2 : row or column out of range -3 : long string truncated to 255 chars

Parameters

int $row

Zero indexed row

int $col

Zero indexed column

string $str

The string to write

mixed $xfIndex

The XF format index for the cell

Returns

int —

_writeLabelSst()

_writeLabelSst(int  $row, int  $col, string  $str, mixed  $xfIndex) : int

Write a string to the specified row and column (zero indexed).

This is the BIFF8 version (no 255 chars limit). $format is optional. Returns 0 : normal termination -2 : row or column out of range -3 : long string truncated to 255 chars

Parameters

int $row

Zero indexed row

int $col

Zero indexed column

string $str

The string to write

mixed $xfIndex

The XF format index for the cell

Returns

int —

_writeNote()

_writeNote(int  $row, int  $col, string  $note) : mixed

Writes a note associated with the cell given by the row and column.

NOTE records don't have a length limit.

Parameters

int $row

Zero indexed row

int $col

Zero indexed column

string $note

The note to write

Returns

mixed —

_writeBoolErr()

_writeBoolErr(int  $row, int  $col, int  $value, bool  $isError, int  $xfIndex) : mixed

Write a boolean or an error type to the specified row and column (zero indexed)

Parameters

int $row

Row index (0-based)

int $col

Column index (0-based)

int $value
bool $isError

Error or Boolean?

int $xfIndex

Returns

mixed —

_writeFormula()

_writeFormula(int  $row, int  $col, string  $formula, mixed  $xfIndex, mixed  $calculatedValue) : int

Write a formula to the specified row and column (zero indexed).

The textual representation of the formula is passed to the parser in Parser.php which returns a packed binary string.

Returns 0 : normal termination -1 : formula errors (bad formula) -2 : row or column out of range

Parameters

int $row

Zero indexed row

int $col

Zero indexed column

string $formula

The formula text string

mixed $xfIndex

The XF format index

mixed $calculatedValue

Calculated value

Returns

int —

_writeStringRecord()

_writeStringRecord(string  $stringValue) : mixed

Write a STRING record. This

Parameters

string $stringValue

Returns

mixed —

_writeUrl()

_writeUrl(int  $row, int  $col, string  $url) : int

Write a hyperlink.

This is comprised of two elements: the visible label and the invisible link. The visible label is the same as the link unless an alternative string is specified. The label is written using the _writeString() method. Therefore the 255 characters string limit applies. $string and $format are optional.

The hyperlink can be to a http, ftp, mail, internal sheet (not yet), or external directory url.

Returns 0 : normal termination -2 : row or column out of range -3 : long string truncated to 255 chars

Parameters

int $row

Row

int $col

Column

string $url

URL string

Returns

int —

_writeRow()

_writeRow(int  $row, int  $height, int  $xfIndex, bool  $hidden = false, int  $level) : mixed

This method is used to set the height and format for a row.

Parameters

int $row

The row to set

int $height

Height we are giving to the row. Use null to set XF without setting height

int $xfIndex

The optional cell style Xf index to apply to the columns

bool $hidden

The optional hidden attribute

int $level

The optional outline level for row, in range [0,7]

Returns

mixed —

_writeDimensions()

_writeDimensions() : mixed

Writes Excel DIMENSIONS to define the area in which there is data.

Returns

mixed —

_writeWindow2()

_writeWindow2() : mixed

Write BIFF record Window2.

Returns

mixed —

_writeDefaultRowHeight()

_writeDefaultRowHeight() : mixed

Write BIFF record DEFAULTROWHEIGHT.

Returns

mixed —

_writeDefcol()

_writeDefcol() : mixed

Write BIFF record DEFCOLWIDTH if COLINFO records are in use.

Returns

mixed —

_writeColinfo()

_writeColinfo(array  $col_array) : mixed

Write BIFF record COLINFO to define column widths

Note: The SDK says the record length is 0x0B but Excel writes a 0x0C length record.

Parameters

array $col_array

This is the only parameter received and is composed of the following: 0 => First formatted column, 1 => Last formatted column, 2 => Col width (8.43 is Excel default), 3 => The optional XF format of the column, 4 => Option flags. 5 => Optional outline level

Returns

mixed —

_writeSelection()

_writeSelection() : mixed

Write BIFF record SELECTION.

Returns

mixed —

_writeMergedCells()

_writeMergedCells() : mixed

Store the MERGEDCELLS records for all ranges of merged cells

Returns

mixed —

_writeSheetLayout()

_writeSheetLayout() : mixed

Write SHEETLAYOUT record

Returns

mixed —

_writeSheetProtection()

_writeSheetProtection() : mixed

Write SHEETPROTECTION

Returns

mixed —

_writeRangeProtection()

_writeRangeProtection() : mixed

Write BIFF record RANGEPROTECTION

Openoffice.org's Documentaion of the Microsoft Excel File Format uses term RANGEPROTECTION for these records Microsoft Office Excel 97-2007 Binary File Format Specification uses term FEAT for these records

Returns

mixed —

_writeExterncount()

_writeExterncount(int  $count) : mixed

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

Excel only stores references to external sheets that are used in formulas. For simplicity we store references to all the sheets in the workbook regardless of whether they are used or not. This reduces the overall complexity and eliminates the need for a two way dialogue between the formula parser the worksheet objects.

Parameters

int $count

The number of external sheet references in this worksheet

Returns

mixed —

_writeExternsheet()

_writeExternsheet(string  $sheetname) : mixed

Writes the Excel BIFF EXTERNSHEET record. These references are used by formulas. A formula references a sheet name via an index. Since we store a reference to all of the external worksheets the EXTERNSHEET index is the same as the worksheet index.

Parameters

string $sheetname

The name of a external worksheet

Returns

mixed —

_writePanes()

_writePanes() : mixed

Writes the Excel BIFF PANE record.

The panes can either be frozen or thawed (unfrozen). Frozen panes are specified in terms of an integer number of rows and columns. Thawed panes are specified in terms of Excel's units for rows and columns.

Returns

mixed —

_writeSetup()

_writeSetup() : mixed

Store the page setup SETUP BIFF record.

Returns

mixed —

_writeHeader()

_writeHeader() : mixed

Store the header caption BIFF record.

Returns

mixed —

_writeFooter()

_writeFooter() : mixed

Store the footer caption BIFF record.

Returns

mixed —

_writeHcenter()

_writeHcenter() : mixed

Store the horizontal centering HCENTER BIFF record.

Returns

mixed —

_writeVcenter()

_writeVcenter() : mixed

Store the vertical centering VCENTER BIFF record.

Returns

mixed —

_writeMarginLeft()

_writeMarginLeft() : mixed

Store the LEFTMARGIN BIFF record.

Returns

mixed —

_writeMarginRight()

_writeMarginRight() : mixed

Store the RIGHTMARGIN BIFF record.

Returns

mixed —

_writeMarginTop()

_writeMarginTop() : mixed

Store the TOPMARGIN BIFF record.

Returns

mixed —

_writeMarginBottom()

_writeMarginBottom() : mixed

Store the BOTTOMMARGIN BIFF record.

Returns

mixed —

_writePrintHeaders()

_writePrintHeaders() : mixed

Write the PRINTHEADERS BIFF record.

Returns

mixed —

_writePrintGridlines()

_writePrintGridlines() : mixed

Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the GRIDSET record.

Returns

mixed —

_writeGridset()

_writeGridset() : mixed

Write the GRIDSET BIFF record. Must be used in conjunction with the PRINTGRIDLINES record.

Returns

mixed —

_writeAutoFilterInfo()

_writeAutoFilterInfo() : mixed

Write the AUTOFILTERINFO BIFF record. This is used to configure the number of autofilter select used in the sheet.

Returns

mixed —

_writeGuts()

_writeGuts() : mixed

Write the GUTS BIFF record. This is used to configure the gutter margins where Excel outline symbols are displayed. The visibility of the gutters is controlled by a flag in WSBOOL.

Returns

mixed —

_writeWsbool()

_writeWsbool() : mixed

Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction with the SETUP record.

Returns

mixed —

_writeBreaks()

_writeBreaks() : mixed

Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records.

Returns

mixed —

_writeProtect()

_writeProtect() : mixed

Set the Biff PROTECT record to indicate that the worksheet is protected.

Returns

mixed —

_writeScenProtect()

_writeScenProtect() : mixed

Write SCENPROTECT

Returns

mixed —

_writeObjectProtect()

_writeObjectProtect() : mixed

Write OBJECTPROTECT

Returns

mixed —

_writePassword()

_writePassword() : mixed

Write the worksheet PASSWORD record.

Returns

mixed —

_writeObjPicture()

_writeObjPicture(int  $colL, int  $dxL, int  $rwT, int  $dyT, int  $colR, int  $dxR, int  $rwB, int  $dyB) : mixed

Store the OBJ record that precedes an IMDATA record. This could be generalise to support other Excel objects.

Parameters

int $colL

Column containing upper left corner of object

int $dxL

Distance from left side of cell

int $rwT

Row containing top left corner of object

int $dyT

Distance from top of cell

int $colR

Column containing lower right corner of object

int $dxR

Distance from right of cell

int $rwB

Row containing bottom right corner of object

int $dyB

Distance from bottom of cell

Returns

mixed —

_writeZoom()

_writeZoom() : mixed

Store the window zoom factor. This should be a reduced fraction but for simplicity we will store all fractions with a numerator of 100.

Returns

mixed —

_writeMsoDrawing()

_writeMsoDrawing() : mixed

Write MSODRAWING record

Returns

mixed —

_writeDataValidity()

_writeDataValidity() : mixed

Store the DATAVALIDATIONS and DATAVALIDATION records.

Returns

mixed —

_mapErrorCode()

_mapErrorCode(string  $errorCode) : int

Map Error code

Parameters

string $errorCode

Returns

int —

_writePageLayoutView()

_writePageLayoutView() : mixed

Write PLV Record

Returns

mixed —

_writeCFRule()

_writeCFRule(\PHPExcel_Style_Conditional  $conditional) : mixed

Write CFRule Record

Parameters

\PHPExcel_Style_Conditional $conditional

Returns

mixed —

_writeCFHeader()

_writeCFHeader() : mixed

Write CFHeader record

Returns

mixed —