2015-07-25 13 views
5

PHPWord'u laravel 5 üzerinde kullanmak istiyorum ancak bunun için herhangi bir paket bulamıyorum. Bu yüzden el ile eklemeye karar verdim ama yine de başarım yok.Laravel'de PHPWord 5

bu öğreticiler ve github dosyaları denedim: Ben sadece dün okuduğumda

Ayrıca bunun bir kısmını gitmişti.

Lütfen yardım edin! Teşekkürler.

composer require phpoffice/phpword 

veya composer.json bu ekleme ardından composer install çalışan toplam:

cevap

11

PHPWord böylece laravel üzerinde yüklemeden, Packagist üzerine kadar kolay olduğunu Kurulduktan

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

yapabilirsiniz kodunuzda bu şekilde kullanın ('dan alınmıştır):

// 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

Çok teşekkürler!! – Xela

+0

Bu PHPWord doc, docx dosyaları oluşturuyor mu? ? – kushalbhaktajoshi

+0

Evet, doc ve docx dosyaları oluşturur. –

İlgili konular