phpmysqlwordpressdocxexport-to-word

Wordpress - Export posts' content to .docx


first of all forgive me for my imperfect english.

I've been digging all over the place but I can't find any solution to what I'm trying to achieve.

I have a Wordpress installation with a number of posts with some custom fields added. I would like to be able to go to the admin panel and tick the posts I want to export, then once I click a button a single .docx file is being generated and prepared for download and this file will contain the content of the posts.

The layout of the .docx file needs to be something like this:

POST 1 TITLE
post 1 content
post 1 custom field value

-----

POST 2 TITLE
post 2 content
post 2 custom field value

-----

POST 3 TITLE
post 3 content
post 3 custom field value

and so on...

So what I'm basically after is a php script that allows me to pull data from some database tables for the selected posts and download it as word/document.xml format but I have no idea where to start from as this topic doesnt seem to be covered anywhere.

If someone would be so kind to point me to the right direction then I would be very very happy.

Thank you very much.


Solution

  • If you would like a manual solution: - Prepare a PHP file with a WP_Query or just a "plain" SQL query to WP database that would fetch the in a format that you need; - Use PHPOffice PHPWord https://github.com/PHPOffice/PHPWord to create a DOCX or DOC file filling it in with the fetched values

    Free plugin that exports posts to DOCX - Aspose DOCX Exporter: https://wordpress.org/plugins/aspose-doc-exporter/

    Non-free: you can use the combination of wpDataTables http://wpdatatables.com to pull the data that you need from the database, and the Report Builder add-on to generate Excel XLSX or Word DOCX document containing the data that you need, you can also prepare a template: http://wpreportbuilder.com/