Data Export (XLS)

How to export data from a table in an Excel file ?

Each collector can call the method downloadXLS or downloadXLSBySQL which allows you to export all or part of the data from a table to an Excel file.

 function downloadXLS($rows = array(), $fields = array(), $addActionColumn = false) { }

Settings

  1. $rows : a table of results.
  2. $fields : a table which will have the key, the name of the column in the database, and for value, the label that will be displayed in column header in Excel.
  3. $addActionColumn : past to true, this parameter has the effect of adding an empty column "Action" which will be a role for data import.

Example

The following example allows you to retrieve a file .xls is showing as well.

$this->collector['example']->downloadXLS(array(array('id_example'=>1, 'lib'=>'Item 1', 'n_order'=>3, 'is_valid'=>1, 'ex_type'=>'EX1')), array('id_example'=>'ID', 'lib'=>'Label', 'n_order'=>'Order'), $addActionColumn=true); 

Method downloadXLSBySql

The method downloadXLSBySql works in the same way, with the difference that the first parameter will correspond to a SQL query directly.

$this->collector['example']->downloadXLSBySql($sql, $fields = array(), $addActionColumn = false);<br /><br />