How to Export the jQuery Datatable data to PDF,Excel,CSV and Copy

In This Post I will show you Exporting functionality with Datatable,PHP and MySQL.I Got huge response from readers on datatable with php tutorials,One of my reader request tutorial about datatable with export features.I have research and found that there are two option to add export features into datatable.

Also Checkout other tutorial of Datatable,

  • Tabletools Plugin : This plugin is used to export table data into pdf,xls,csv etc. using swf object but right its out dated.
  • ExportButton Plugin : This plugin used to export table data into pdf,xls,csv etc. using HTML5.

So i have taken option 2, I am integrating Export Button on Datatable with PHP.

i got one more issue with export Button datatable plugin,You can not get full export data into pdf,excel etc. using ajax request,You can get only visible records into exported pdf,excel etc file.

I have used NON ajax manner to export datatable data with PHP.

Export DataTable Data Using Button Plugin and PHP

In this post I will demonstrate, how to add Export functionality in datatable using Export Button Plugin.You can export data in CSV,PDF,Excel etc format as well as Copy the table data into clipboard.Please keep in mind these functionality will work only HTML5 supported browser.

We will cover following functionality in this Datatable Tutorial

  • Load one time data into table
  • Export and Save Datatable data into CSV
  • Export and Save Datatable data into PDF
  • Export and Save Datatable data into Excel
  • You can Copy datatable data into clipboard
  • You can Print the datatable data

Adding Necessary jQuery Datatable library and Plugins

We will include all necessary plugin and library files to export data from datatable.

We have used Datatable download builder tools generated js and css files.

Initialization Of dataTable on HTML Table

We can initialize export Button by simply adding ‘B’ into DOM element.

Adding and customizing Export Button

We can add and customize Export Button using button json object.

Here we passed copy,excel,csv,pdf and print options into 'button' JavaScript array.This will contains all options button which you want show under Export Button.I have changed default button text to “Export” using “text” option.

The server code is same is my previous Datatable with PHP,mysql and Ajax article.

You can download source code and Demo from below link.