1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
   | private PdfPTable generateTable(int nombreColonne, String[] chaineRubrique, boolean borderRub, String[]chaineValeur, boolean borderVal) throws DocumentException{          
 
    String[] listeRubrique = null;
    String[] listeValeur = null;
    int compteur = 0;
    int compteurval;
    //int savei = 0;
    boolean gras = false;
    //boolean pcirestant;
    boolean maskpcco = false;
 
    PdfPTable table = new PdfPTable(nombreColonne);
    table.setWidthPercentage(100);
 
    int tailleChaineRubrique = chaineRubrique.length;
    tailleChaineRubrique--;
 
    // tableau de PCCO
    for (int i = 0; i <= tailleChaineRubrique; i++) {
 
        boolean pcirestant = true;
 
        // recupération des PCCO et de leurs infos
        while(pcirestant){
 
            compteur=0;
 
            listeRubrique = chaineRubrique[i].split(";");
            int tailleListeRubrique = listeRubrique.length;
            tailleListeRubrique--;
 
            //liste de PCCO            
            for (int j = 0; j <= tailleListeRubrique; j++) {
 
                compteur++;
                compteurval = 0;
 
                PdfPCell cell = new PdfPCell();
                Paragraph para;
 
                if(maskpcco)
                    para = new Paragraph("");
                else    
                    para = new Paragraph(listeRubrique[j]);
 
                para.font().setSize(8);
 
                cell.setPaddingTop(4);
                if(!borderRub)
                    cell.setBorder(0);
                //colonne 1
                if(compteur==1){
                    para.setAlignment(Paragraph.ALIGN_CENTER);
                }
                //colonne 2
                if(compteur==2){
                    para.setAlignment(Paragraph.ALIGN_LEFT);
                    cell.setColspan(3);
                }
                //colonne 3
                if(compteur==3){
                    para.setAlignment(Paragraph.ALIGN_RIGHT);
                    compteur=0;
                }
                cell.addElement(para);
                table.addCell(cell);
 
                //liste des PCI                
                if ( j == tailleListeRubrique ) {
 
                    //ajout de la liste des PCI
 
                    //récupération de la liste des PCI
                    listeValeur = chaineValeur[i].split(";");
                    int tailleListeValeur = listeValeur.length;
                    tailleListeValeur--;
 
                    for(int z=0;z<=2;z++){
 
                        cell = new PdfPCell();
                        para = new Paragraph(listeValeur[compteurval]);
                        if(!borderVal)
                            cell.setBorder(0);
 
                        switch(z) {
                            case 0:
                                para.setAlignment(Paragraph.ALIGN_CENTER);
                                break;
 
                            case 1:
                                para.setAlignment(Paragraph.ALIGN_LEFT);
                                cell.setColspan(3);
                                //TODO vérifier le fonctionnement
                                if(listeValeur[j].equalsIgnoreCase("total")){
                                    para.font().setStyle(Font.BOLD);
                                    para.font().setSize(9);
                                    gras = true;
                                    pcirestant=false;
                                }
                                break;
 
                            case 2:
                                para.setAlignment(Paragraph.ALIGN_RIGHT);
                                if(gras){
                                    para.font().setStyle(Font.BOLD);
                                    para.font().setSize(9);
                                    gras=false;
                                }
                                break;
                        }
                        compteurval++;
                        maskpcco = true;
                        cell.addElement(para);
                        table.addCell(cell);
                    }
                }
            }
        }
    }
 
    return table;
} | 
Partager