add sample

fix undefined Index
This commit is contained in:
jogo 2014-07-04 15:31:48 +02:00
parent 87c3df5536
commit 7c8ff2884b
2 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,22 @@
<?php
include_once 'Sample_Header.php';
// New Word document
echo date('H:i:s'), " Create new PhpWord object", EOL;
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addTitle( 'This is page 1', 1 );
$linkIsInternal = true;
$section->addLink('MyBookmark', 'Take me to page 3', null ,null,$linkIsInternal);
$section->addPageBreak();
$section->addTitle( 'This is page 2', 1 );
$section->addPageBreak();
$section->addTitle( 'This is page 3', 1 );
$section->addBookmark('MyBookmark');
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}

View File

@ -139,7 +139,7 @@ class PhpWord
/** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collectionObject */
$collectionObject = $this->collections[$key];
return $collectionObject->addItem($args[0]);
return $collectionObject->addItem(array_key_exists(0,$args) ? $args[0] : null);
}
// Run add style method