source: ether_megapoli/trunk/service/implementation/com/medias/integration_old/lecture_ecriture/LecturePersonnes.java @ 486

Last change on this file since 486 was 486, checked in by vmipsl, 12 years ago

BO insertion données _ ajout code medias
clean

  • Property svn:executable set to *
File size: 2.9 KB
Line 
1/*
2 * Created on 29 Jan. 2007
3 */
4/**
5 * @author
6 *
7 *
8 */
9package integration.lecture_ecriture;
10
11import com.medias.Constantes;
12import jxl.Sheet;
13import jxl.Workbook;
14import jxl.WorkbookSettings;
15import jxl.read.biff.BiffException;
16
17import java.io.File;
18import java.io.IOException;
19import java.util.ArrayList;
20
21public class LecturePersonnes {
22        public LecturePersonnes() {
23        }
24
25        public void lireFichier() {
26                String nomFichierPers = Constantes.cheminListes + "/" + Constantes.nomListePersonnes;
27                File fichier = new File(nomFichierPers);
28                if (fichier.exists()) {
29                        // Etape ou l' on crée le Workbook
30                        Workbook workbook = null;
31                        try {
32                                WorkbookSettings ws = new WorkbookSettings();
33                                ws.setEncoding(Constantes.encodageDefaut);
34                                workbook = Workbook.getWorkbook(fichier, ws);
35                        } catch (BiffException e) {
36                                e.printStackTrace();
37                        } catch (IOException e) {
38                                e.printStackTrace();
39                        }
40                        // Etape ou l'on récupére les données de la 1ére page du classeur
41                        Sheet sheet = workbook.getSheet(0);
42                       
43                        // Erape d'initialisisations des listes
44                        numerosPers = new ArrayList<String>();
45                        nomsPers = new ArrayList<String>();
46                        prenomsPers = new ArrayList<String>();
47                        mailsPers = new ArrayList<String>();
48                        descriptionsPers = new ArrayList<String>();
49                        numOrgsPers = new ArrayList<String>();
50
51                        nbPersonnes = sheet.getRows() - 1;//Constantes.nbPersonnes;
52                        // Etape de lecture des cellules
53                        for (int numPers = 0; numPers < nbPersonnes; numPers++) {
54                                numerosPers.add(sheet.getCell(0, numPers + 1).getContents());
55                                nomsPers.add(sheet.getCell(1, numPers + 1).getContents());
56                                prenomsPers.add(sheet.getCell(2, numPers + 1).getContents());
57                                mailsPers.add(sheet.getCell(3, numPers + 1).getContents());
58                                descriptionsPers.add(sheet.getCell(4, numPers + 1).getContents());
59                                numOrgsPers.add(sheet.getCell(5, numPers + 1).getContents());
60                        }
61                        // Etape de fermeture du flux
62                        workbook.close();
63                }
64        }
65       
66        public int getIndice(int numero) {
67                int indice = -1;
68                int numeroCourant;
69                for (int indiceListe = 0; indiceListe < numerosPers.size(); indiceListe++) {
70                        numeroCourant = Integer.parseInt((String)numerosPers.get(indiceListe));
71                        if (numeroCourant == numero) {
72                                indice = indiceListe;
73                                return indice;
74                        }
75                }
76                return indice;
77        }
78
79        public ArrayList<String> getNumerosPers() {
80                return numerosPers;
81        }
82
83        public ArrayList<String> getNomsPers() {
84                return nomsPers;
85        }
86
87        public ArrayList<String> getPrenomsPers() {
88                return prenomsPers;
89        }
90
91        public ArrayList<String> getMailsPers() {
92                return mailsPers;
93        }
94
95        public ArrayList<String> getDescriptionsPers() {
96                return descriptionsPers;
97        }
98
99        public ArrayList<String> getNumOrgsPers() {
100                return numOrgsPers;
101        }
102
103        private ArrayList<String> numerosPers;
104
105        private ArrayList<String> nomsPers;
106
107        private ArrayList<String> prenomsPers;
108
109        private ArrayList<String> mailsPers;
110
111        private ArrayList<String> descriptionsPers;
112
113        private ArrayList<String> numOrgsPers;
114
115        private int nbPersonnes;
116}
Note: See TracBrowser for help on using the repository browser.