PHPExcel_Writer_Excel5_Worksheet

category | PHPExcel
package | PHPExcel_Writer_Excel5
copyright | Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)

### Methods

## Constructor

    __construct(int $str_total, int $str_unique, array $str_table, array $colors, mixed $parser, boolean $preCalculateFormulas, string | \PHPExcel_Worksheet $phpSheet)

### Parameters

#### $str_total

`int`

&$str_total Total number of strings

#### $str_unique

`int`

&$str_unique Total number of unique strings

#### $str_table

`array`

&$str_table String Table

#### $colors

`array`

&$colors Colour Table

#### $parser

`mixed`

The formula parser created for the Workbook

#### $preCalculateFormulas

`boolean`

Flag indicating whether formulas should be calculated or just written

#### $phpSheet

`string``\PHPExcel_Worksheet`

The worksheet to write

## Excel limits the size of BIFF records.

    _addContinue(string $data) : string

Inherited

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.

access | private
inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::_addContinue()

### Parameters

#### $data

`string`

The original binary data to be written

### Returns

`string`A very convenient string of continue blocks

## General storage function

    _append(string $data)

Inherited

access | private
inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::_append()

### Parameters

#### $data

`string`

binary data to append

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

    _positionImage(integer $col_start, integer $row_start, integer $x1, integer $y1, integer $width, integer $height)

+------------+------------+ | 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.

access | private

### Parameters

#### $col_start

`integer`

Col containing upper left corner of object

#### $row_start

`integer`

Row containing top left corner of object

#### $x1

`integer`

Distance to left side of object

#### $y1

`integer`

Distance to top of object

#### $width

`integer`

Width of image frame

#### $height

`integer`

Height of image frame

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

    _processBitmap(string $bitmap) : array

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

access | private

### Parameters

#### $bitmap

`string`

The bitmap to process

### Returns

`array`Array with data and properties of the bitmap

## Convert a GD-image into the internal format.

    _processBitmapGd(resource $image) : array

access | private

### Parameters

#### $image

`resource`

The image to process

### Returns

`array`Array with data and properties of the bitmap

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

    _storeBof(integer $type)

Inherited

access | private
inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::_storeBof()

### Parameters

#### $type

`integer`

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

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

    _storeEof()

Inherited

access | private
inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::_storeEof()

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

    _writeBlank(integer $row, integer $col, mixed $xfIndex)

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

#### $row

`integer`

Zero indexed row

#### $col

`integer`

Zero indexed column

#### $xfIndex

`mixed`

The XF format index

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

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

./../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.

access | private
see | \_writeUrl()

### Parameters

#### $row1

`integer`

Start row

#### $col1

`integer`

Start column

#### $row2

`integer`

End row

#### $col2

`integer`

End column

#### $url

`string`

URL string

### Returns

`integer`

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

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

access | private
see | \_writeUrl()

### Parameters

#### $row1

`integer`

Start row

#### $col1

`integer`

Start column

#### $row2

`integer`

End row

#### $col2

`integer`

End column

#### $url

`string`

URL string

### Returns

`integer`

## This is the more general form of _writeUrl().

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

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').

access | private
see | \_writeUrl()

### Parameters

#### $row1

`integer`

Start row

#### $col1

`integer`

Start column

#### $row2

`integer`

End row

#### $col2

`integer`

End column

#### $url

`string`

URL string

### Returns

`integer`

## Used to write http, ftp and mailto hyperlinks.

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

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

access | private
see | \_writeUrl()

### Parameters

#### $row1

`integer`

Start row

#### $col1

`integer`

Start column

#### $row2

`integer`

End row

#### $col2

`integer`

End column

#### $url

`string`

URL string

### Returns

`integer`

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

    close()

access | public
see | \PHPExcel_Writer_Excel5_Workbook::storeWorkbook()

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

    getByteOrder() : int

InheritedStatic

inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::getByteOrder()

### Returns

`int`

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

    getData() : string

### Returns

`string`The data

## Get Escher object

    getEscher() : \PHPExcel_Shared_Escher

### Returns

`\PHPExcel_Shared_Escher`

## Insert a 24bit bitmap image in a worksheet.

    insertBitmap(integer $row, integer $col, mixed $bitmap, integer $x, integer $y, float $scale_x, float $scale_y)

access | public

### Parameters

#### $row

`integer`

The row we are going to insert the bitmap into

#### $col

`integer`

The column we are going to insert the bitmap into

#### $bitmap

`mixed`

The bitmap filename or GD-image resource

#### $x

`integer`

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

#### $y

`integer`

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

#### $scale_x

`float`

The horizontal scale

#### $scale_y

`float`

The vertical scale

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

    printRowColHeaders(integer $print)

access | public

### Parameters

#### $print

`integer`

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

## Set Escher object

    setEscher(\PHPExcel_Shared_Escher $pValue)

### Parameters

#### $pValue

`\PHPExcel_Shared_Escher`

## This method sets the properties for outlining and grouping.

    setOutline(bool $visible, bool $symbols_below, bool $symbols_right, bool $auto_style)

The defaults correspond to Excel's defaults.

### Parameters

#### $visible

`bool`

#### $symbols_below

`bool`

#### $symbols_right

`bool`

#### $auto_style

`bool`

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

    writeData(string $data) : string

Inherited

inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::writeData()

### Parameters

#### $data

`string`

binary data to write

### Returns

`string`

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

    writeEof()

Inherited

access | private
inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::writeEof()

## Map Error code

    _mapErrorCode(string $errorCode) : int

Static

### Parameters

#### $errorCode

`string`

### Returns

`int`

## Write the AUTOFILTERINFO BIFF record.

    _writeAutoFilterInfo()

This is used to configure the number of autofilter select used in the sheet.

## 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

    _writeBIFF8CellRangeAddressFixed(string $range) : string

### Parameters

#### $range

`string`

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

### Returns

`string`Binary data

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

    _writeBoolErr(int $row, int $col, int $value, boolean $isError, int $xfIndex)

### Parameters

#### $row

`int`

Row index (0-based)

#### $col

`int`

Column index (0-based)

#### $value

`int`

#### $isError

`boolean`

Error or Boolean?

#### $xfIndex

`int`

## Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records.

    _writeBreaks()

## Write CFHeader record

    _writeCFHeader()

## Write CFRule Record

    _writeCFRule(\PHPExcel_Style_Conditional $conditional)

### Parameters

#### $conditional

`\PHPExcel_Style_Conditional`

## Write BIFF record COLINFO to define column widths

    _writeColinfo(array $col_array)

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

### Parameters

#### $col_array

`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

## Store the DATAVALIDATIONS and DATAVALIDATION records.

    _writeDataValidity()

## Write BIFF record DEFAULTROWHEIGHT.

    _writeDefaultRowHeight()

## Write BIFF record DEFCOLWIDTH if COLINFO records are in use.

    _writeDefcol()

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

    _writeDimensions()

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

    _writeExterncount(integer $count)

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

#### $count

`integer`

The number of external sheet references in this worksheet

## Writes the Excel BIFF EXTERNSHEET record.

    _writeExternsheet(string $sheetname)

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

#### $sheetname

`string`

The name of a external worksheet

## Store the footer caption BIFF record.

    _writeFooter()

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

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

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

#### $row

`integer`

Zero indexed row

#### $col

`integer`

Zero indexed column

#### $formula

`string`

The formula text string

#### $xfIndex

`mixed`

The XF format index

#### $calculatedValue

`mixed`

Calculated value

### Returns

`integer`

## Write the GRIDSET BIFF record.

    _writeGridset()

Must be used in conjunction with the PRINTGRIDLINES record.

## Write the GUTS BIFF record.

    _writeGuts()

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.

see | \_writeWsbool()

## Store the horizontal centering HCENTER BIFF record.

    _writeHcenter()

access | private

## Store the header caption BIFF record.

    _writeHeader()

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

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

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

access | public

### Parameters

#### $row

`integer`

Zero indexed row

#### $col

`integer`

Zero indexed column

#### $str

`string`

The string to write

#### $xfIndex

`mixed`

The XF format index for the cell

### Returns

`integer`

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

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

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

access | public

### Parameters

#### $row

`integer`

Zero indexed row

#### $col

`integer`

Zero indexed column

#### $str

`string`

The string to write

#### $xfIndex

`mixed`

The XF format index for the cell

### Returns

`integer`

## Store the BOTTOMMARGIN BIFF record.

    _writeMarginBottom()

## Store the LEFTMARGIN BIFF record.

    _writeMarginLeft()

## Store the RIGHTMARGIN BIFF record.

    _writeMarginRight()

## Store the TOPMARGIN BIFF record.

    _writeMarginTop()

## Store the MERGEDCELLS records for all ranges of merged cells

    _writeMergedCells()

## Write MSODRAWING record

    _writeMsoDrawing()

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

    _writeNote(integer $row, integer $col, string $note)

NOTE records don't have a length limit.

### Parameters

#### $row

`integer`

Zero indexed row

#### $col

`integer`

Zero indexed column

#### $note

`string`

The note to write

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

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

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

#### $row

`integer`

Zero indexed row

#### $col

`integer`

Zero indexed column

#### $num

`float`

The number to write

#### $xfIndex

`mixed`

The optional XF format

### Returns

`integer`

## Store the OBJ record that precedes an IMDATA record.

    _writeObjPicture(integer $colL, integer $dxL, integer $rwT, integer $dyT, integer $colR, integer $dxR, integer $rwB, integer $dyB)

This could be generalise to support other Excel objects.

### Parameters

#### $colL

`integer`

Column containing upper left corner of object

#### $dxL

`integer`

Distance from left side of cell

#### $rwT

`integer`

Row containing top left corner of object

#### $dyT

`integer`

Distance from top of cell

#### $colR

`integer`

Column containing lower right corner of object

#### $dxR

`integer`

Distance from right of cell

#### $rwB

`integer`

Row containing bottom right corner of object

#### $dyB

`integer`

Distance from bottom of cell

## Write OBJECTPROTECT

    _writeObjectProtect()

## Write PLV Record

    _writePageLayoutView()

## Writes the Excel BIFF PANE record.

    _writePanes()

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.

## Write the worksheet PASSWORD record.

    _writePassword()

## Write the PRINTGRIDLINES BIFF record.

    _writePrintGridlines()

Must be used in conjunction with the GRIDSET record.

## Write the PRINTHEADERS BIFF record.

    _writePrintHeaders()

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

    _writeProtect()

## Write BIFF record RANGEPROTECTION

    _writeRangeProtection()

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

## Write a LABELSST record or a LABEL record.

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

Which one depends on BIFF version It differs from _writeString by the writing of rich text strings.

### Parameters

#### $row

`int`

Row index (0-based)

#### $col

`int`

Column index (0-based)

#### $str

`string`

The string

#### $xfIndex

`mixed`

The XF format index for the cell

#### $arrcRun

`array`

Index to Font record and characters beginning

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

    _writeRow(integer $row, integer $height, integer $xfIndex, bool $hidden, integer $level)

### Parameters

#### $row

`integer`

The row to set

#### $height

`integer`

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

#### $xfIndex

`integer`

The optional cell style Xf index to apply to the columns

#### $hidden

`bool`

The optional hidden attribute

#### $level

`integer`

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

## Write SCENPROTECT

    _writeScenProtect()

## Write BIFF record SELECTION.

    _writeSelection()

## Store the page setup SETUP BIFF record.

    _writeSetup()

## Write SHEETLAYOUT record

    _writeSheetLayout()

## Write SHEETPROTECTION

    _writeSheetProtection()

## Write a LABELSST record or a LABEL record.

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

Which one depends on BIFF version

### Parameters

#### $row

`int`

Row index (0-based)

#### $col

`int`

Column index (0-based)

#### $str

`string`

The string

#### $xfIndex

`int`

Index to XF record

## Write a STRING record.

    _writeStringRecord(string $stringValue)

This

### Parameters

#### $stringValue

`string`

## Write a hyperlink.

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

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

#### $row

`integer`

Row

#### $col

`integer`

Column

#### $url

`string`

URL string

### Returns

`integer`

## Store the vertical centering VCENTER BIFF record.

    _writeVcenter()

## Write BIFF record Window2.

    _writeWindow2()

## Write the WSBOOL BIFF record, mainly for fit-to-page.

    _writeWsbool()

Used in conjunction with the SETUP record.

## Store the window zoom factor.

    _writeZoom()

This should be a reduced fraction but for simplicity we will store all fractions with a numerator of 100.

### Properties

##

    $_active_pane : integer

##

    $_colinfo : array

##

    $_data : string

Inherited

inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::$$_data

##

    $_datasize : integer

Inherited

Should be the same as strlen($this->_data)

inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::$$_datasize

##

    $_fntHashIndex : array

##

    $_limit : integer

Inherited

See _addContinue()

see | \_addContinue()
inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::$$_limit

##

    $_outline_below : bool

##

    $_outline_on : integer

##

    $_outline_right : bool

##

    $_outline_style : bool

##

    $_phpSheet : \PHPExcel_Worksheet

##

    $_selection : array

##

    $_str_table : array

##

    $_str_total : integer

##

    $_str_unique : integer

##

    $_xls_strmax : integer

##

    $_byte_order : integer

Inherited

0 => little endian, 1 => big endian

inherited_from | \PHPExcel_Writer_Excel5_BIFFwriter::$$_byte_order

##

    $_colors

##

    $_countCellStyleXfs : int

##

    $_escher : \PHPExcel_Shared_Escher

##

    $_firstColumnIndex : int

##

    $_firstRowIndex : int

##

    $_lastColumnIndex : int

##

    $_lastRowIndex : int

(no used rows means -1)

##

    $_parser : \PHPExcel_Writer_Excel5_Parser