PHP code example of lopo / olef

1. Go to this page and download the library: Download lopo/olef library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lopo / olef example snippets


$b = str_repeat("\x00", 10000);

$of = new \OleF\OleFile;
$myStream = $of->RootStorage->addStream('MyStream');

$myStream->setData($b);
$of->saveAs('MyCompoundFile.cfs');
$of->close();

//A xls file should have a Workbook stream
$of = \OleF\OleFile::open('report.xls');
$foundStream = $of->RootStorage->getStream('Workbook');
$temp = $foundStream->getData();
// do something with $temp
$of->close();

// Open existing file in update mode (or create new one first)
$of = \OleF\OleFile::open('existing.cfs', true);
$st = $of->RootStorage->addStorage('MyStorage');
$sm = $st->addStream('MyStream');

$of->RootStorage->delete('AStream'); // 'AStream' item is assumed to exist

$of->RootStorage->addStream('MyStream')->setData($buffer);
$of->commit();

\OleF\OleFile::shrinkOleFile('MultipleStorage_Deleted_Compress.cfs');

$of = \OleF\OleFile::open('report.xls');
$pc = new \OleF\Extensions\OLEProperties\OLEPropertiesContainer($of->RootStorage->getStream("\x05SummaryInformation"));
foreach ($pc->Properties as $p) {
    // ...
}