Rajout d'un export Excel
[zf2.biz/galerie.git] / module / Galerie / src / Galerie / Export / GalerieWorkbook.php
1 <?php
2
3 namespace Galerie\Export;
4
5 use Custom\Export\AbstractWorkbook;
6
7
8 class GalerieWorkbook extends AbstractWorkbook
9 {
10
11     /**
12      * Nom du fichier utilisé pour l'export.
13      *
14      * @return string
15      */
16     protected function nomFichier()
17     {
18         return 'export_galerie.xls';
19     }
20
21
22
23
24     /**
25      * Méthode d'écriture des données dans la feuille courante.
26      *
27      * @return null
28      */
29     protected function writeData()
30     {
31         $this->ecrireCaseCourante("Nom", 'titre_string');
32         $this->ecrireCaseCourante("Description", 'titre_string');
33         $this->ecrireCaseCourante("Propriétaire", 'titre_string');
34         $this->ecrireCaseCourante("Photos", 'titre_string');
35         $this->nextLine();
36         foreach($this->datas as $d) {
37             $this->ecrireCaseCourante($d->name, 'case_string');
38             $this->ecrireCaseCourante($d->description, 'case_string');
39             $this->ecrireCaseCourante($d->username, 'case_string');
40             $this->ecrireCaseCourante($d->nb, 'case_chiffre');
41             $this->nextLine();
42         }
43     }
44
45
46
47
48     /**
49      * Mise en forme après écriture.
50      *
51      * @return null
52      */
53     protected function postFormats()
54     {
55         $this->current_worksheet->setColumn(0, 0, '10');
56         $this->current_worksheet->setColumn(1, 1, '40');
57         $this->current_worksheet->setColumn(2, 2, '10');
58         $this->current_worksheet->setColumn(3, 3, '5');
59
60         $this->current_worksheet->setRow(0, 50);
61         $c = count($this->datas);
62         for($i=1;$i<=$c;$i++) {
63             $this->current_worksheet->setRow($i, 30);
64         }
65
66         $this->current_worksheet->setLandscape();
67         $this->current_worksheet->hideGridLines();
68     }  
69
70 }
71