Introduction

This is not a common problem, but still important. If you want to export data from a web app to Microsoft Word or Open/Libre Office, you will mostlikely use PHPWord.

PHPWord is a great choice for this, because you can define templates, that means, that you can write a Word document, and include tags to replace in it.

However, PHPWord does not allow the conversion of HTML marked-up text to OpenXML, the markup of Microsoft Office documents.

You don’t have to build a HTML to OpenXML converter yourselfe.

You can use H2OXML (https://h2openxml.codeplex.com/) to process your html text by using this code:

//include the library
require_once "HTMLtoOpenXML.php";


//convert
$toOpenXML = HTMLtoOpenXML::getInstance()->fromHTML("<p>te<b>s</b>t</p>");