Rajout d'un export Excel
[zf2.biz/galerie.git] / module / Galerie / src / Galerie / Export / GalerieWorkbook.php
diff --git a/module/Galerie/src/Galerie/Export/GalerieWorkbook.php b/module/Galerie/src/Galerie/Export/GalerieWorkbook.php
new file mode 100644 (file)
index 0000000..2e55466
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+
+namespace Galerie\Export;
+
+use Custom\Export\AbstractWorkbook;
+
+
+class GalerieWorkbook extends AbstractWorkbook
+{
+
+    /**
+     * Nom du fichier utilisé pour l'export.
+     *
+     * @return string
+     */
+    protected function nomFichier()
+    {
+        return 'export_galerie.xls';
+    }
+
+
+
+
+    /**
+     * Méthode d'écriture des données dans la feuille courante.
+     *
+     * @return null
+     */
+    protected function writeData()
+    {
+        $this->ecrireCaseCourante("Nom", 'titre_string');
+        $this->ecrireCaseCourante("Description", 'titre_string');
+        $this->ecrireCaseCourante("Propriétaire", 'titre_string');
+        $this->ecrireCaseCourante("Photos", 'titre_string');
+        $this->nextLine();
+        foreach($this->datas as $d) {
+            $this->ecrireCaseCourante($d->name, 'case_string');
+            $this->ecrireCaseCourante($d->description, 'case_string');
+            $this->ecrireCaseCourante($d->username, 'case_string');
+            $this->ecrireCaseCourante($d->nb, 'case_chiffre');
+            $this->nextLine();
+        }
+    }
+
+
+
+
+    /**
+     * Mise en forme après écriture.
+     *
+     * @return null
+     */
+    protected function postFormats()
+    {
+        $this->current_worksheet->setColumn(0, 0, '10');
+        $this->current_worksheet->setColumn(1, 1, '40');
+        $this->current_worksheet->setColumn(2, 2, '10');
+        $this->current_worksheet->setColumn(3, 3, '5');
+
+        $this->current_worksheet->setRow(0, 50);
+        $c = count($this->datas);
+        for($i=1;$i<=$c;$i++) {
+            $this->current_worksheet->setRow($i, 30);
+        }
+
+        $this->current_worksheet->setLandscape();
+        $this->current_worksheet->hideGridLines();
+    }  
+
+}
+