PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (210)   DownloadInstall with Composer Download .zip   Reputation   Support forum (27)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 73%Total: 5,883 This week: 2All time: 395 This week: 84Up
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  
Name: Raskin Veniamin <contact>
Classes: 12 packages by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 2207 in Russian Federation Russian Federation
Week rank: 103 Up7 in Russian Federation Russian Federation Equal
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  
File Role Description
Files folder imagedocumentation (139 files)
Files folder imageexamples (10 files)
Files folder imagevsword (3 files, 3 directories)

  Files folder image Files  /  documentation  
File Role Description
  Accessible without login HTML file 404.html Doc. Documentation
  Accessible without login HTML file class-AlignNode.html Doc. Documentation
  Accessible without login HTML file class-ArbitraryCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-ArbitraryNode.html Doc. Documentation
  Accessible without login HTML file class-AttachVsWord.html Doc. Documentation
  Accessible without login HTML file class-BodyCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-BoldStyleNode.html Doc. Documentation
  Accessible without login HTML file class-BrNode.html Doc. Documentation
  Accessible without login HTML file class-BrNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-CompositeNode.html Doc. Documentation
  Accessible without login HTML file class-ContentTypesStructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-DefaultInitNode.html Doc. Documentation
  Accessible without login HTML file class-DefNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-DocPropsDirA...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-DocPropsDirC...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-DocumentCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-DrawingNode.html Doc. Documentation
  Accessible without login HTML file class-DrawingNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-EmptyCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-Exception.html Doc. Documentation
  Accessible without login HTML file class-FontSizeStyleNode.html Doc. Documentation
  Accessible without login HTML file class-HTMLLoader.html Doc. Documentation
  Accessible without login HTML file class-HtmlParser.html Doc. Documentation
  Accessible without login HTML file class-HyperlinkCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-IBlockContext.html Doc. Documentation
  Accessible without login HTML file class-IInitNode.html Doc. Documentation
  Accessible without login HTML file class-ILineContext.html Doc. Documentation
  Accessible without login HTML file class-INode.html Doc. Documentation
  Accessible without login HTML file class-INodeStyle.html Doc. Documentation
  Accessible without login HTML file class-INodeStyleAdded.html Doc. Documentation
  Accessible without login HTML file class-INodeTextAdded.html Doc. Documentation
  Accessible without login HTML file class-IPNodeStyle.html Doc. Documentation
  Accessible without login HTML file class-IPNodeStyleAdded.html Doc. Documentation
  Accessible without login HTML file class-ItalicStyleNode.html Doc. Documentation
  Accessible without login HTML file class-ListCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-ListCompositeNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-ListItemCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-ListItemComp...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-ListStyle.html Doc. Documentation
  Accessible without login HTML file class-MyInitNode.html Doc. Documentation
  Accessible without login HTML file class-Node.html Doc. Documentation
  Accessible without login HTML file class-NodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-PageBreakNode.html Doc. Documentation
  Accessible without login HTML file class-Parser.html Doc. Documentation
  Accessible without login HTML file class-PCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-PCompositeNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-PPrCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-RCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-RCompositeNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-RelsDirRelsStructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-RPrCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-StringNode.html Doc. Documentation
  Accessible without login HTML file class-StructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-Style.html Doc. Documentation
  Accessible without login HTML file class-TableColCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-TableColComp...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-TableCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-TableCompositeNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-TableRowCompositeNode.html Doc. Documentation
  Accessible without login HTML file class-TableRowComp...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file class-TableStyle.html Doc. Documentation
  Accessible without login HTML file class-TextNode.html Doc. Documentation
  Accessible without login HTML file class-UnderlineStyleNode.html Doc. Documentation
  Accessible without login HTML file class-VsWord.html Doc. Documentation
  Accessible without login HTML file class-WordDirDocum...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-WordDirFontT...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-WordDirRelsD...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-WordDirSetti...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-WordDirStylesStructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-WordDirStyle...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-WordDirTheme...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-WordDirWebSe...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file class-ZipArchive.html Doc. Documentation
  Accessible without login Plain text file elementlist.js Data Auxiliary data
  Accessible without login HTML file index.html Doc. Documentation
  Accessible without login HTML file package-PHP.html Doc. Documentation
  Accessible without login HTML file package-vsword.html Doc. Documentation
  Accessible without login HTML file package-vsword.node.html Doc. Documentation
  Accessible without login HTML file package-vsword.parser.addesed.html Doc. Documentation
  Accessible without login HTML file package-vsword.parser.html Doc. Documentation
  Accessible without login HTML file package-vsword.structure.html Doc. Documentation
  Accessible without login HTML file package-vsword.structure.style.html Doc. Documentation
  Accessible without login HTML file source-class-AlignNode.html Doc. Documentation
  Accessible without login HTML file source-class-ArbitraryCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-ArbitraryNode.html Doc. Documentation
  Accessible without login HTML file source-class-AttachVsWord.html Doc. Documentation
  Accessible without login HTML file source-class-BodyCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-BoldStyleNode.html Doc. Documentation
  Accessible without login HTML file source-class-BrNode.html Doc. Documentation
  Accessible without login HTML file source-class-BrNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-CompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-Conte...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file source-class-DefaultInitNode.html Doc. Documentation
  Accessible without login HTML file source-class-DefNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-DocPr...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file source-class-DocPr...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file source-class-DocumentCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-DrawingNode.html Doc. Documentation
  Accessible without login HTML file source-class-DrawingNodeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-EmptyCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-FontSizeStyleNode.html Doc. Documentation
  Accessible without login HTML file source-class-HTMLLoader.html Doc. Documentation
  Accessible without login HTML file source-class-HtmlParser.html Doc. Documentation
  Accessible without login HTML file source-class-HyperlinkCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-IBlockContext.html Doc. Documentation
  Accessible without login HTML file source-class-IInitNode.html Doc. Documentation
  Accessible without login HTML file source-class-ILineContext.html Doc. Documentation
  Accessible without login HTML file source-class-INode.html Doc. Documentation
  Accessible without login HTML file source-class-INodeStyle.html Doc. Documentation
  Accessible without login HTML file source-class-INodeStyleAdded.html Doc. Documentation
  Accessible without login HTML file source-class-INodeTextAdded.html Doc. Documentation
  Accessible without login HTML file source-class-IPNodeStyle.html Doc. Documentation
  Accessible without login HTML file source-class-IPNodeStyleAdded.html Doc. Documentation
  Accessible without login HTML file source-class-ItalicStyleNode.html Doc. Documentation
  Accessible without login HTML file source-class-ListCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-ListC...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-ListItemCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-ListI...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-ListStyle.html Doc. Documentation
  Accessible without login HTML file source-class-MyInitNode.html Doc. Documentation
  Accessible without login HTML file source-class-Node.html Doc. Documentation
  Accessible without login HTML file source-class-NodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-PageBreakNode.html Doc. Documentation
  Accessible without login HTML file source-class-Parser.html Doc. Documentation
  Accessible without login HTML file source-class-PCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-PComp...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-PPrCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-RCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-RComp...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-RelsD...ructureDocFile.html Doc. Documentation
  Accessible without login HTML file source-class-RPrCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-StringNode.html Doc. Documentation
  Accessible without login HTML file source-class-StructureDocFile.html Doc. Documentation
  Accessible without login HTML file source-class-Style.html Doc. Documentation
  Accessible without login HTML file source-class-TableColCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-Table...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-TableCompositeNode.html Doc. Documentation
  Accessible without login HTML file source-class-Table...odeNodeAddeded.html Doc. Documentation
  Accessible without login HTML file source-class-TableRowCompositeNode.html Doc. Documentation

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file align.php Example Example script
  Accessible without login Plain text file base.php Example Example script
  Accessible without login Plain text file htmlparser.php Example Example script
  Accessible without login Plain text file htmlparser_yourstyle.php Example Example script
  Accessible without login Image file img1.jpg Photo Photograph
  Accessible without login Plain text file pagebreak.php Example Example script
  Accessible without login Plain text file table.php Example Example script
  Accessible without login Plain text file table2.php Example Example script
  Accessible without login Plain text file tinymce.php Example Example script
  Accessible without login Plain text file tree.php Example Example script

  Files folder image Files  /  vsword  
File Role Description
Files folder imagenode (27 files)
Files folder imageparser (4 files, 1 directory)
Files folder imagestructure (13 files, 1 directory)
  Plain text file AttachVsWord.php Class Class source
  Plain text file interfaces.php Class Class source
  Plain text file VsWord.php Class Class source

  Files folder image Files  /  vsword  /  node  
File Role Description
  Plain text file AlignNode.php Class Class source
  Plain text file ArbitraryCompositeNode.php Class Class source
  Plain text file ArbitraryNode.php Class Class source
  Plain text file BodyCompositeNode.php Class Class source
  Plain text file BoldStyleNode.php Class Class source
  Plain text file BrNode.php Class Class source
  Plain text file CompositeNode.php Class Class source
  Plain text file DocumentCompositeNode.php Class Class source
  Plain text file DrawingNode.php Class Class source
  Plain text file EmptyCompositeNode.php Class Class source
  Plain text file FontSizeStyleNode.php Class Class source
  Plain text file HyperlinkCompositeNode.php Class Class source
  Plain text file ItalicStyleNode.php Class Class source
  Plain text file ListCompositeNode.php Class Class source
  Plain text file ListItemCompositeNode.php Class Class source
  Plain text file Node.php Class Class source
  Plain text file PageBreakNode.php Class Class source
  Plain text file PCompositeNode.php Class Class source
  Plain text file PPrCompositeNode.php Class Class source
  Plain text file RCompositeNode.php Class Class source
  Plain text file RPrCompositeNode.php Class Class source
  Plain text file StringNode.php Class Class source
  Plain text file TableColCompositeNode.php Class Class source
  Plain text file TableCompositeNode.php Class Class source
  Plain text file TableRowCompositeNode.php Class Class source
  Plain text file TextNode.php Class Class source
  Plain text file UnderlineStyleNode.php Class Class source

  Files folder image Files  /  vsword  /  parser  
File Role Description
Files folder imageaddeded (11 files)
  Plain text file DefaultInitNode.php Class Class source
  Plain text file HTMLLoader.php Class Class source
  Plain text file HtmlParser.php Class Class source
  Plain text file Parser.php Class Class source

  Files folder image Files  /  vsword  /  parser  /  addeded  
File Role Description
  Plain text file BrNodeNodeAddeded.php Class Class source
  Plain text file DefNodeAddeded.php Class Class source
  Plain text file DrawingNodeNodeAddeded.php Class Class source
  Plain text file ListCompositeNodeNodeAddeded.php Class Class source
  Plain text file ListItemCompositeNodeNodeAddeded.php Class Class source
  Plain text file NodeAddeded.php Class Class source
  Plain text file PCompositeNodeNodeAddeded.php Class Class source
  Plain text file RCompositeNodeNodeAddeded.php Class Class source
  Plain text file TableColCompositeNodeNodeAddeded.php Class Class source
  Plain text file TableCompositeNodeNodeAddeded.php Class Class source
  Plain text file TableRowCompositeNodeNodeAddeded.php Class Class source

  Files folder image Files  /  vsword  /  structure  
File Role Description
Files folder imagestyle (3 files)
  Plain text file ContentTypesStructureDocFile.php Class Class source
  Plain text file DocPropsDirAppStructureDocFile.php Class Class source
  Plain text file DocPropsDirCoreStructureDocFile.php Class Class source
  Plain text file RelsDirRelsStructureDocFile.php Class Class source
  Plain text file StructureDocFile.php Class Class source
  Plain text file WordDirDocumentStructureDocFile.php Class Class source
  Plain text file WordDirFontTableStructureDocFile.php Class Class source
  Plain text file WordDirRelsDirDocu...tructureDocFile.php Class Class source
  Plain text file WordDirSettingsStructureDocFile.php Class Class source
  Plain text file WordDirStylesStructureDocFile.php Class Class source
  Plain text file WordDirStylesWithE...tructureDocFile.php Class Class source
  Plain text file WordDirThemeDirThemeStructureDocFile.php Class Class source
  Plain text file WordDirWebSettingsStructureDocFile.php Class Class source

  Files folder image Files  /  vsword  /  structure  /  style  
File Role Description
  Plain text file ListStyle.php Class Class source
  Plain text file Style.php Class Class source
  Plain text file TableStyle.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:5,883
This week:2
All time:395
This week:84Up
User Ratings User Comments (2)
 All time
Utility:93%StarStarStarStarStar
Consistency:87%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:90%StarStarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:126
 
useful and cool)
9 years ago (Havok)
80%StarStarStarStarStar
cool
9 years ago (Yves Marie HAMAYON)
70%StarStarStarStar