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 = 4096

OLE_LONG_INT_SIZE

OLE_LONG_INT_SIZE = 4

OLE_PPS_SIZE

OLE_PPS_SIZE = 128

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

$bbat

$bbat : array

Big Block Allocation Table.

Type

array — (blockId => nextBlockId)

$sbat

$sbat : array

Short Block Allocation Table.

Type

array — (blockId => nextBlockId)

$bigBlockSize

$bigBlockSize : integer

Size of big blocks. This is usually 512.

Type

integer — number of octets per block

$smallBlockSize

$smallBlockSize : integer

Size of small blocks. This is usually 64.

Type

integer — number of octets per block

$bigBlockThreshold

$bigBlockThreshold : integer

Threshold for big blocks.

Type

integer

Methods

read()

read(string  $file) : boolean

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

Parameters

string $file

Throws

\PhpOffice\PhpSpreadsheet\Reader\Exception

Returns

boolean —

true on success, PEAR_Error on failure

_getBlockOffset()

_getBlockOffset(integer  $blockId) : integer

Parameters

integer $blockId

byte offset from beginning of file

Returns

integer

getStream()

getStream(integer|\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

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

block id or PPS

Returns

resource —

read-only stream

_readPpsWks()

_readPpsWks(integer  $blockId) : boolean

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

Parameters

integer $blockId

the block id of the first block

Returns

boolean —

true on success, PEAR_Error on failure

_ppsTreeComplete()

_ppsTreeComplete(integer  $index) : boolean

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

Parameters

integer $index

The index of the PPS from which we are checking

Returns

boolean —

Whether the PPS tree for the given PPS is complete

isFile()

isFile(integer  $index) : boolean

Checks whether a PPS is a File PPS or not.

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

Parameters

integer $index

The index for the PPS

Returns

boolean —

true if it's a File PPS, false otherwise

isRoot()

isRoot(integer  $index) : boolean

Checks whether a PPS is a Root PPS or not.

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

Parameters

integer $index

the index for the PPS

Returns

boolean —

true if it's a Root PPS, false otherwise

ppsTotal()

ppsTotal() : integer

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

Returns

integer —

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

getData()

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

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

Parameters

integer $index

The index for the PPS

integer $position

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

integer $length

The amount of bytes to read (at most)

Returns

string —

The binary string containing the data requested

getDataLength()

getDataLength(integer  $index) : integer

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

Parameters

integer $index

The index for the PPS

Returns

integer —

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(integer  $date) : string

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

Parameters

integer $date

A timestamp

Returns

string —

The string for the OLE container

OLE2LocalDate()

OLE2LocalDate(integer  $string) : string

Returns a timestamp from an OLE container's date.

Parameters

integer $string

A binary string with the encoded date

Returns

string —

The timestamp corresponding to the string

_readInt1()

_readInt1(resource  $fh) : integer

Reads a signed char.

Parameters

resource $fh

file handle

Returns

integer

_readInt2()

_readInt2(resource  $fh) : integer

Reads an unsigned short (2 octets).

Parameters

resource $fh

file handle

Returns

integer

_readInt4()

_readInt4(resource  $fh) : integer

Reads an unsigned long (4 octets).

Parameters

resource $fh

file handle

Returns

integer