Blog

Export data to Excel wordpress

In order to export data to Excel, you need to connect PHPExcel.php. This library is needed download, and upload to your theme folder.
We connect it with the following code in the functions.php of your theme:

Next we need to call the export function, I used the GET request:

You also need to think about security, for example, so that this request can only be performed by the administrator:

In the example, I will consider exporting user data, in principle, this option can be altered to fit your needs, because he is universal. The entire request code will look like this:

As a result, an Excel document will be saved on your PC with user data.
In principle, instead of selecting user data, you can select anything, whether it is a page, post or product, and substitute the desired data.

If you need to get a document with two or more tabs, then you need to write the following code after the rename code of the first tab:

This code creates a new tab and makes it active.

© Copyright 2014 -  vchuy-develop.com. All rights reserved