Export Data to Excel, PDF, CSV, and HTML

export_icons

  

phpGrid currently supports export in native Excel format, CSV, PDF, and HTML format. When the export feature is enabled, phpGrid displays an export icon in the footer. Users can export data to Excel in php or any one of the supported file formats Also see enable_export().

 
If you want to enable users to export data from the PHP grids, you should enable this feature. By default, users can export to Microsoft Office Excel, PDF, HTML, or CSV any list of data that appears in a grid. Export to Excel produces native Microsoft Excel .xls file format.
 
Native Excel .xls format is now supported in version 6.7. Previously Excel export is in OpenOffice XML .xml format.
X
Users can export data to Excel in php or any one of the supported file formats by clicking the Export button that appears in the footer. Users can only export data appears in the datagrid. All hidden columns made with set_col_hidden() are not included in the export. It is not recommended to enable export feature when the datagrid contains data such as social security numbers or passwords.
 
When users click Export button, the phpGrid will generate the export file by using data from the database table in Ajax. Data that does not appear on the screen is not exported. If search filter is used, only the filtered results are exported.
 

When the datagrid contains fields that reference to others database tables through lookups, the text will be used in the export rather than the id fields. Please check out the “select” control type in set_col_edittype function.

 
PDF and CSV formats are now supported (Available to Professional and Enterprise Licenses) !
 

grid-export

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
// change column titles
$dg->set_col_title("orderNumber", "Order No.");
$dg->set_col_title("orderDate", "Order Date");
$dg->set_col_title("shippedDate", "Shipped Date");
$dg->set_col_title("customerNumber", "Customer No.");
// hide a column
$dg->set_col_hidden("requiredDate");
// change default caption
$dg->set_caption("Orders List");
// EXCEL export
$dg->enable_export('PDF');
$dg->display();

$dg2 = new C_DataGrid("select * from customers", "customerNumber", "Customers");
// PDF export
$dg2->enable_export('EXCEL');
$dg2->display();

See Live Demo!