Constants

OLE_PPS_TYPE_ROOT

OLE_PPS_TYPE_ROOT = 5

OLE_PPS_TYPE_DIR

OLE_PPS_TYPE_DIR = 1

OLE_PPS_TYPE_FILE

OLE_PPS_TYPE_FILE = 2

OLE_DATA_SIZE_SMALL

OLE_DATA_SIZE_SMALL = 0x1000

OLE_LONG_INT_SIZE

OLE_LONG_INT_SIZE = 4

OLE_PPS_SIZE

OLE_PPS_SIZE = 0x80

Properties

$_file_handle

$_file_handle : resource

The file handle for reading an OLE container.

Type

resource

$_list

$_list : array

Array of PPS's found on the OLE container.

Type

array

$root

$root : \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\Root

Root directory of OLE container.

Type

Root

$bbat

$bbat : array

Big Block Allocation Table.

Type

array — (blockId => nextBlockId)

$sbat

$sbat : array

Short Block Allocation Table.

Type

array — (blockId => nextBlockId)

$bigBlockSize

$bigBlockSize : int

Size of big blocks. This is usually 512.

Type

int — number of octets per block

$smallBlockSize

$smallBlockSize : int

Size of small blocks. This is usually 64.

Type

int — number of octets per block

$bigBlockThreshold

$bigBlockThreshold : int

Threshold for big blocks.

Type

int

Methods

read()

read(string  $file) : bool

Reads an OLE container from the contents of the file given.

Parameters

string $file

Returns

bool —

true on success, PEAR_Error on failure

getBlockOffset()

getBlockOffset(int  $blockId) : int

Parameters

int $blockId

byte offset from beginning of file

Returns

int —

getStream()

getStream(int|\PhpOffice\PhpSpreadsheet\Shared\OLE\PPS  $blockIdOrPps) : resource

Returns a stream for use with fread() etc. External callers should use \PhpOffice\PhpSpreadsheet\Shared\OLE\PPS\File::getStream().

Parameters

int|\PhpOffice\PhpSpreadsheet\Shared\OLE\PPS $blockIdOrPps

block id or PPS

Returns

resource —

read-only stream

readPpsWks()

readPpsWks(int  $blockId) : bool

Gets information about all PPS's on the OLE container from the PPS WK's creates an OLE_PPS object for each one.

Parameters

int $blockId

the block id of the first block

Returns

bool —

true on success, PEAR_Error on failure

isFile()

isFile(int  $index) : bool

Checks whether a PPS is a File PPS or not.

If there is no PPS for the index given, it will return false.

Parameters

int $index

The index for the PPS

Returns

bool —

true if it's a File PPS, false otherwise

isRoot()

isRoot(int  $index) : bool

Checks whether a PPS is a Root PPS or not.

If there is no PPS for the index given, it will return false.

Parameters

int $index

the index for the PPS

Returns

bool —

true if it's a Root PPS, false otherwise

ppsTotal()

ppsTotal() : int

Gives the total number of PPS's found in the OLE container.

Returns

int —

The total number of PPS's found in the OLE container

getData()

getData(int  $index, int  $position, int  $length) : string

Gets data from a PPS If there is no PPS for the index given, it will return an empty string.

Parameters

int $index

The index for the PPS

int $position

The position from which to start reading (relative to the PPS)

int $length

The amount of bytes to read (at most)

Returns

string —

The binary string containing the data requested

getDataLength()

getDataLength(int  $index) : int

Gets the data length from a PPS If there is no PPS for the index given, it will return 0.

Parameters

int $index

The index for the PPS

Returns

int —

The amount of bytes in data the PPS has

ascToUcs()

ascToUcs(string  $ascii) : string

Utility function to transform ASCII text to Unicode.

Parameters

string $ascii

The ASCII string to transform

Returns

string —

The string in Unicode

localDateToOLE()

localDateToOLE(int  $date) : string

Utility function Returns a string for the OLE container with the date given.

Parameters

int $date

A timestamp

Returns

string —

The string for the OLE container

OLE2LocalDate()

OLE2LocalDate(string  $oleTimestamp) : int

Returns a timestamp from an OLE container's date.

Parameters

string $oleTimestamp

A binary string with the encoded date

Returns

int —

The Unix timestamp corresponding to the string

readInt1()

readInt1(resource  $fh) : int

Reads a signed char.

Parameters

resource $fh

file handle

Returns

int —

readInt2()

readInt2(resource  $fh) : int

Reads an unsigned short (2 octets).

Parameters

resource $fh

file handle

Returns

int —

readInt4()

readInt4(resource  $fh) : int

Reads an unsigned long (4 octets).

Parameters

resource $fh

file handle

Returns

int —

ppsTreeComplete()

ppsTreeComplete(int  $index) : bool

It checks whether the PPS tree is complete (all PPS's read) starting with the given PPS (not necessarily root).

Parameters

int $index

The index of the PPS from which we are checking

Returns

bool —

Whether the PPS tree for the given PPS is complete