teqneers / phpword
PHPWord is a library written in PHP that create word documents.
Installs: 39 182
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 6
Forks: 5
Open Issues: 0
Requires
- php: >5.2.0
This package is auto-updated.
Last update: 2024-12-08 07:34:27 UTC
README
This repository is an source code of PHPWord, turned into Composer package. This repository is forked from ferdynator.
Installation
All you have to do is to get composer and add following lines to your composer.json
:
"require": {
"teqneers/phpword": "*"
}
Examples
CantSplit in Tables
Prevents the splitting of a table row if the content does not fit on the page. The whole row moves to a new page. See http://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.cantsplit(v=office.14).aspx
... $wordTable = $section->addTable('tableStyle'); $wordTable->setCantSplit(true); ...
Usage of tab stops
<?php require_once '../PHPWord.php'; // New Word Document $PHPWord = new PHPWord(); $PHPWord->addParagraphStyle('multipleTab', array( 'tabs' => array( new PHPWord_Style_Tab("left", 1550), new PHPWord_Style_Tab("center", 3200), new PHPWord_Style_Tab("right", 5300) ) )); $PHPWord->addParagraphStyle('rightTab', array( 'tabs' => array( new PHPWord_Style_Tab("right", 9090) ) )); $PHPWord->addParagraphStyle('centerTab', array( 'tabs' => array( new PHPWord_Style_Tab("center", 4680) ) )); // New portrait section $section = $PHPWord->createSection(); // Add listitem elements $section->addText("Multiple Tabs:\tOne\tTwo\tThree", NULL, 'multipleTab'); $section->addText("Left Aligned\tRight Aligned", NULL, 'rightTab'); $section->addText("\tCenter Aligned", NULL, 'centerTab'); // Save File $objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('TabStops.docx'); ?>