Membuat word document dengan php

require_once 'PHPWord.php';
$PHPWord = new PHPWord();

// New portrait section
$section = $PHPWord->createSection();

// Add text elements
$section->addText('Hello World!');

$section->addText('I am inline styled.', array('name'=>'Verdana', 'color'=>'006699'));

$PHPWord->addFontStyle('myOwnTextStyle', array('bold'=>true, 'italic'=>true, 'size'=>16));
$section->addText('I am styled by style definition.', 'myOwnTextStyle');

//Download Section
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=file_name.docx");
header("Content-Type: application/docx");

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');



source :

This entry was posted in php. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.