PHP Classes

VS PHP Word HTML: Create DOCX Word document dynamically from HTML

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 69%Total: 5,914 All time: 391 This week: 30Up
Version License PHP version Categories
vsword 1.0.14GNU General Publi...5.0PHP 5, Files and Folders, Parsers
Description 

Author

This class can create DOCX Word document dynamically from HTML.

It can create a Microsoft Word document adding document elements dynamically.

It can also parse given HTML code and add the page elements to the Word document.

The generated Word DOCX file is saved to a file with a given name.

Innovation Award
PHP Programming Innovation award winner
January 2015
Winner


Prize: One copy of the Zend Studio
Many applications need to create word processing documents in Microsoft Word XML DOCX format.

Solutions for this problem can be based on composing Word documents dynamically adding elements to the document one by one, or converting existing HTML documents to the DOCX format.

This package provides both solutions, so the developer can use the HTML already generated to present information on his application Web pages and then add or modify other document elements programmatically.

Manuel Lemos
Picture of Raskin Veniamin
  Performance   Level  
Innovation award
Innovation award
Nominee: 6x

Winner: 1x

 

Recommendations

Create MS .doc files
Use PHP to create files in MS .doc format

What is the best PHP docx class?
Not understanding how to style

Example

<?php
/**
* This example demonstrates the parsing HTML string and convert it into the document.
*/
require_once '../vsword/VsWord.php';
VsWord::autoLoad();

$doc = new VsWord();
$parser = new HtmlParser($doc);
$parser->parse('<h1>Hello world!</h1>');
$parser->parse('<h3>Hello world!</h3>');
$parser->parse('<p>Hello world!</p>');
$parser->parse('<h2>Header table</h2><table><tr><td>Coll 1</td><td>Coll 2</td></tr></table>');
$parser->parse($html);

echo
'<pre>'.($doc->getDocument()->getBody()->look()).'</pre>';

$doc->saveAs('htmlparser.docx');


  Files folder image Files (210)  
File Role Description
Files folder imagedocumentation (139 files)
Files folder imageexamples (10 files)
Files folder imagevsword (3 files, 3 directories)

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:5,914
This week:0
All time:391
This week:30Up
User Ratings User Comments (2)
 All time
Utility:88%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:80%StarStarStarStarStar
Examples:86%StarStarStarStarStar
Tests:-
Videos:-
Overall:69%StarStarStarStar
Rank:337
 
useful and cool)
10 years ago (Havok)
80%StarStarStarStarStar
cool
10 years ago (Yves Marie HAMAYON)
70%StarStarStarStar