Export des données avec EEDataExporterBundle

Par Timothee Ngu, il y a 10 ans


Slut à tous, pour Exporter les données, j'utilise le bundle EEDataExporterBundle. après installation j'ai créer une action dans mon controller pour exporter les données mais je suis bloqué.

public function userAction() { $em = $this->getDoctrine()->getManager(); $scores= $em->getRepository('AppEleveBundle:Score')->findAll(); $exporter = $this->get('ee.dataexporter'); $exporter->setOptions('csv', array('fileName' => 'users', 'separator' => ';')); $exporter->setColumns(array('[id]', '[nom]', '[matiere]', '[competence]', '[evaluation]')); $exporter->setData(array( array('id' => 'xxx', 'scores.user' => 'xxx','matiere' => 'xxx', 'competence' => 'xxx', 'evaluation' => 'xxx'), )); return $exporter->render(); }

2 réponses

nico41, il y a 10 ans

Un truc du genre :

$exporter->setColumns(array('[id]', '[nom]', '[matiere]', '[competence]', '[evaluation]')); $datas = []; foreach($scores as $score){ $datas[] = [ "id"=>$score->getId(), "nom"=> ??? , "matiere"=> ??? , "competence"=> ??? , "evaluation"=> ???, ]; } $exporter->setData($datas); return $exporter->render();

ton projet est visible sur github ?

Timothee Ngu, il y a 10 ans

Ca marche.