Sample 16 Object

17:52:19 Create new PhpWord object
17:52:19 Write to Word2007 format
17:52:20 Write to ODText format
17:52:20 Write to RTF format
17:52:20 Write to HTML format
17:52:20 Write to PDF format ... NOT DONE!
17:52:20 Write to EPub3 format
17:52:20 Done writing file(s)
17:52:20 Peak memory usage: 2 MB

 

Results: docx odt rtf html epub

<?php

include_once 'Sample_Header.php';

// New Word document
echo date('H:i:s'), ' Create new PhpWord object', EOL;
$phpWord = new PhpOffice\PhpWord\PhpWord();

// Begin code
$section = $phpWord->addSection();
$section->addText('You can open this OLE object by double clicking on the icon:');
$section->addTextBreak(2);
$section->addOLEObject(__DIR__ . '/resources/_sheet.xls');

// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}