PFZ.nl - PHP Community: Doc of Docx - Frameworks - Forum - PFZ.nl - PHP Community

Je kunt niet antwoorden op dit topic
#1 14-01-2012 12:36
Ik wil een Doc of Docx genereren zoals je pdf met fpdf kunt genereren. Ik heb twee site gezien: http://www.zend.com en http://www.phpword.codeplex.com.
Ik zoek geen lib, maar een class, die je dus bij elke hoster eenvoudig kunt uploaden, zoals fpdf. Ik kan niet vinden of dat met zend of phpword het geval is. Wie weet dit of heeft een alternatief?

#2 14-01-2012 13:41
Ik zou voor PHPWord gaan.

En dat werkt net zo eenvoudig als fpdf. Heb je de Examples al eens bekeken?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Include the PHPWord.php, all other classes were loaded by an autoloader
require_once 'PHPWord.php';

// Create a new PHPWord Object
$PHPWord = new PHPWord();

// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $PHPWord->createSection();

// After creating a section, you can append elements:
$section->addText('Hello world!');

// You can directly style your text by giving the addText function an array:
$section->addText('Hello world! I am formatted.', array('name'=>'Tahoma', 'size'=>16, 'bold'=>true));

// If you often need the same style again you can create a user defined style to the word document
// and give the addText function the name of the style:
$PHPWord->addFontStyle('myOwnStyle', array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232'));
$section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle');

// You can also putthe appended element to local object an call functions like this:
$myTextElement = $section->addText('Hello World!');
$myTextElement->setBold();
$myTextElement->setName('Verdana');
$myTextElement->setSize(22);

// At least write the document to webspace:
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('helloWorld.docx');
Wees ze voor en voorkom SQL Injection & Cross Site Scripting!


Inloggen wachtwoord vergeten? Aanmelden