Documentation

Worksheet extends BIFFwriter
in package

Table of Contents

Constants

MAX_XLS_COLUMN  = 256
MAX_XLS_COLUMN_STRING  = 'IV'
MAX_XLS_ROW  = 65536
WRITE_FORMULA_ERRORS  = -1
WRITE_FORMULA_EXCEPTION  = -3
WRITE_FORMULA_NORMAL  = 0
WRITE_FORMULA_RANGE  = -2

Properties

$_data  : string|null
The string containing the data of the BIFF stream.
$_datasize  : int
The size of the data in bytes. Should be the same as strlen($this->_data).
$fontHashIndex  : array<string|int, int|string>
Array of font hashes associated to FONT records index.
$phpSheet  : Worksheet
Sheet object.

Methods

__construct()  : mixed
Constructor.
close()  : void
Add data to the beginning of the workbook (note the reverse order) and to the end of the workbook.
getAllowThrow()  : bool
getByteOrder()  : int
Determine the byte order and store it as class data to avoid recalculating it for each call to new().
getData()  : string
Retrieves data from memory in one chunk, or from disk sized chunks.
getEscher()  : Escher|null
Get Escher object.
insertBitmap()  : void
Insert a 24bit bitmap image in a worksheet.
positionImage()  : void
Calculate the vertices that define the position of the image as required by the OBJ record.
printRowColHeaders()  : void
Set the option to print the row and column headers on the printed page.
processBitmap()  : array<string|int, mixed>
Convert a 24 bit bitmap into the modified internal format used by Windows.
processBitmapGd()  : array{0: float, 1: float, 2: int, 3: string}
Convert a GD-image into the internal format.
setAllowThrow()  : void
setEscher()  : void
Set Escher object.
setOutline()  : void
This method sets the properties for outlining and grouping. The defaults correspond to Excel's defaults.
writeBlank()  : int
Write a blank cell to the specified row and column (zero indexed).
writeData()  : string
General storage function like append, but returns string instead of modifying $this->_data.
writeEof()  : string
Writes Excel EOF record to indicate the end of a BIFF stream.
writeUrlWeb()  : void
Used to write http, ftp and mailto hyperlinks.
append()  : void
General storage function.
storeBof()  : void
Writes Excel BOF record to indicate the beginning of a stream or sub-stream in the BIFF file.
storeEof()  : void
Writes Excel EOF record to indicate the end of a BIFF stream.

Constants

MAX_XLS_COLUMN

public mixed MAX_XLS_COLUMN = 256

MAX_XLS_COLUMN_STRING

public mixed MAX_XLS_COLUMN_STRING = 'IV'

MAX_XLS_ROW

public mixed MAX_XLS_ROW = 65536

WRITE_FORMULA_ERRORS

public mixed WRITE_FORMULA_ERRORS = -1

WRITE_FORMULA_EXCEPTION

public mixed WRITE_FORMULA_EXCEPTION = -3

WRITE_FORMULA_NORMAL

public mixed WRITE_FORMULA_NORMAL = 0

WRITE_FORMULA_RANGE

public mixed WRITE_FORMULA_RANGE = -2

Properties

$_data

The string containing the data of the BIFF stream.

public string|null $_data

$_datasize

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

public int $_datasize

$fontHashIndex

Array of font hashes associated to FONT records index.

public array<string|int, int|string> $fontHashIndex

Methods

__construct()

Constructor.

public __construct(int &$str_total, int &$str_unique, array<string, int> &$str_table, array<string|int, mixed> &$colors, Parser $parser, bool $preCalculateFormulas, Worksheet $phpSheet[, Workbook|null $writerWorkbook = null ]) : mixed
Parameters
$str_total : int

Total number of strings

$str_unique : int

Total number of unique strings

$str_table : array<string, int>

String Table

$colors : array<string|int, mixed>

Colour Table

$parser : Parser

The formula parser created for the Workbook

$preCalculateFormulas : bool

Flag indicating whether formulas should be calculated or just written

$phpSheet : Worksheet

The worksheet to write

$writerWorkbook : Workbook|null = null

close()

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

public close() : void
Tags
see
Workbook::storeWorkbook

getAllowThrow()

public static getAllowThrow() : bool
Return values
bool

getByteOrder()

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

public static getByteOrder() : int
Return values
int

getData()

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

public getData() : string
Return values
string

The data

insertBitmap()

Insert a 24bit bitmap image in a worksheet.

public insertBitmap(int $row, int $col, GdImage|string $bitmap[, int $x = 0 ][, int $y = 0 ][, float $scale_x = 1 ][, float $scale_y = 1 ]) : void
Parameters
$row : int

The row we are going to insert the bitmap into

$col : int

The column we are going to insert the bitmap into

$bitmap : GdImage|string

The bitmap filename or GD-image resource

$x : int = 0

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

$y : int = 0

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

$scale_x : float = 1

The horizontal scale

$scale_y : float = 1

The vertical scale

positionImage()

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

public positionImage(int $col_start, int $row_start, int $x1, int $y1, int $width, int $height) : void

+------------+------------+ | 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
$col_start : int

Col containing upper left corner of object

$row_start : int

Row containing top left corner of object

$x1 : int

Distance to left side of object

$y1 : int

Distance to top of object

$width : int

Width of image frame

$height : int

Height of image frame

printRowColHeaders()

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

public printRowColHeaders([int $print = 1 ]) : void
Parameters
$print : int = 1

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

processBitmap()

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

public processBitmap(string $bitmap) : array<string|int, mixed>

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

Parameters
$bitmap : string

The bitmap to process

Return values
array<string|int, mixed>

Array with data and properties of the bitmap

processBitmapGd()

Convert a GD-image into the internal format.

public processBitmapGd(GdImage $image) : array{0: float, 1: float, 2: int, 3: string}
Parameters
$image : GdImage

The image to process

Return values
array{0: float, 1: float, 2: int, 3: string}

Data and properties of the bitmap

setAllowThrow()

public static setAllowThrow(bool $allowThrow) : void
Parameters
$allowThrow : bool

setEscher()

Set Escher object.

public setEscher(Escher|null $escher) : void
Parameters
$escher : Escher|null

setOutline()

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

public setOutline([bool $visible = true ][, bool $symbols_below = true ][, bool $symbols_right = true ][, bool $auto_style = false ]) : void
Parameters
$visible : bool = true
$symbols_below : bool = true
$symbols_right : bool = true
$auto_style : bool = false

writeBlank()

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

public writeBlank(int $row, int $col, int $xfIndex) : int

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 : int

Zero indexed row

$col : int

Zero indexed column

$xfIndex : int

The XF format index

Return values
int

writeData()

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

public writeData(string $data) : string
Parameters
$data : string

binary data to write

Return values
string

writeEof()

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

public writeEof() : string
Return values
string

writeUrlWeb()

Used to write http, ftp and mailto hyperlinks.

public writeUrlWeb(int $row1, int $col1, int $row2, int $col2, string $url) : void

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
$row1 : int

Start row

$col1 : int

Start column

$row2 : int

End row

$col2 : int

End column

$url : string

URL string

Tags
see
writeUrl()

append()

General storage function.

protected append(string $data) : void
Parameters
$data : string

binary data to append

storeBof()

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

protected storeBof(int $type) : void
Parameters
$type : int

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

storeEof()

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

protected storeEof() : void

        
On this page

Search results