// *Note Download SimpleExcel : http://faisalman.github.com/simple-excel-php/ // *twitter.com/quocvuongdn use SimpleExcel\SimpleExcel; require '../lib/SimpleExcel/SimpleExcel.php'; public function exportToXml($results,$fileName){ //$result is ResultSet from query DB, $fileName is name of xml file. //Export to xml, can see it on excel office. $rowHead = array(); foreach ($results[0] as $key => $value) { array_push($rowHead, $key); } $rowData = array(); array_push($rowData, $rowHead); //Put column name to [0] position array. foreach ($results as $key => $value) { array_push($rowData, $value); //Put data to array. } $this->excel->writer->setData($rowData); //Set array to data of xml file. $this->excel->writer->saveFile($fileName); //Set name file. }