2015-07-25 15 views

Antwort

11

PHPWord ist auf Packagist, so dass es auf Laravel Installation ist so einfach wie:

composer require phpoffice/phpword 

oder das Hinzufügen dieses dann zu Ihrem composer.json composer install ausgeführt wird:

"require": { 
    "phpoffice/phpword": "dev-master" 
} 

Einmal installiert können Sie verwenden sie es in Ihrem Code wie folgt (aus dem documentation):

// Creating the new document... 
$phpWord = new \PhpOffice\PhpWord\PhpWord(); 

/* Note: any element you append to a document must reside inside of a Section. */ 

// Adding an empty Section to the document... 
$section = $phpWord->addSection(); 

// Adding Text element to the Section having font styled by default... 
$section->addText(
    htmlspecialchars(
     '"Learn from yesterday, live for today, hope for tomorrow. ' 
      . 'The important thing is not to stop questioning." ' 
      . '(Albert Einstein)' 
    ) 
); 

// Saving the document as HTML file... 
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); 
$objWriter->save('helloWorld.html'); 
+0

Vielen Dank!! – Xela

+0

Erstellt dieses PHPWord doc, docx Dateien? ? – kushalbhaktajoshi

+0

Ja, es erstellt doc und docx Dateien. –