class OLE (View source)

OLE package base class.

Constants

OLE_PPS_TYPE_ROOT

OLE_PPS_TYPE_DIR

OLE_PPS_TYPE_FILE

OLE_DATA_SIZE_SMALL

OLE_LONG_INT_SIZE

OLE_PPS_SIZE

Properties

resource $_file_handle The file handle for reading an OLE container.
array $_list Array of PPS's found on the OLE container.
Root $root Root directory of OLE container.
array $bbat Big Block Allocation Table.
array $sbat Short Block Allocation Table.
int $bigBlockSize Size of big blocks. This is usually 512.
int $smallBlockSize Size of small blocks. This is usually 64.
int $bigBlockThreshold Threshold for big blocks.

Methods

bool
read(string $file)

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

int
_getBlockOffset(int $blockId)

No description

resource
getStream(int|PPS $blockIdOrPps)

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

bool
_readPpsWks(int $blockId)

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

bool
_ppsTreeComplete(int $index)

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

bool
isFile(int $index)

Checks whether a PPS is a File PPS or not.

bool
isRoot(int $index)

Checks whether a PPS is a Root PPS or not.

int
ppsTotal()

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

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

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

int
getDataLength(int $index)

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

static string
ascToUcs(string $ascii)

Utility function to transform ASCII text to Unicode.

static string
localDateToOLE(int $date)

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

static string
OLE2LocalDate(int $string)

Returns a timestamp from an OLE container's date.

Details

bool read(string $file)

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

Parameters

string $file

Return Value

bool true on success, PEAR_Error on failure

Exceptions

Exception

int _getBlockOffset(int $blockId)

Parameters

int $blockId byte offset from beginning of file

Return Value

int

resource getStream(int|PPS $blockIdOrPps)

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

Parameters

int|PPS $blockIdOrPps block id or PPS

Return Value

resource read-only stream

bool _readPpsWks(int $blockId)

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

Return Value

bool true on success, PEAR_Error on failure

bool _ppsTreeComplete(int $index)

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

Return Value

bool Whether the PPS tree for the given PPS is complete

bool isFile(int $index)

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

Return Value

bool true if it's a File PPS, false otherwise

bool isRoot(int $index)

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

Return Value

bool true if it's a Root PPS, false otherwise

int ppsTotal()

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

Return Value

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

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

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)

Return Value

string The binary string containing the data requested

See also

int getDataLength(int $index)

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

Return Value

int The amount of bytes in data the PPS has

static string ascToUcs(string $ascii)

Utility function to transform ASCII text to Unicode.

Parameters

string $ascii The ASCII string to transform

Return Value

string The string in Unicode

static string localDateToOLE(int $date)

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

Parameters

int $date A timestamp

Return Value

string The string for the OLE container

static string OLE2LocalDate(int $string)

Returns a timestamp from an OLE container's date.

Parameters

int $string A binary string with the encoded date

Return Value

string The timestamp corresponding to the string