| 12
 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
 
 |  
try {
            //Si un evenement ne possede pas d'heure de début, il dur toute la journée et il débute a 0h
            if(listP[6]!=(-1)){
                nbCase=nbDemiHeure(listP[6], listP[7], listP[8], listP[9]);
                positionV=positionVertical(listP[6],listP[8]);
            }
            else{
                nbCase=48;
                positionV=2;
            }
 
            System.out.println("------Création dans le fichier Excel------");
            System.out.println("nbcase: "+nbCase);
            System.out.println("positionV: "+positionV);
            System.out.println("------------------------------------------");
 
            FileOutputStream fileOut;
 
            POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(path));
            HSSFWorkbook wb = new HSSFWorkbook(fs);
            HSSFSheet sheet = wb.getSheetAt(0);
            HSSFRow row ;            
            HSSFCell cell = null;
            HSSFCellStyle cellStyle = null;
 
            row = sheet.createRow(positionV-1);
            cell = row.createCell( listP[4]);
            cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setCellValue(new HSSFRichTextString(resume));
            cellStyle = wb.createCellStyle();
            cellStyle.setFillForegroundColor(ChangeCouleur(listP[6], listP[8]));
            CellRangeAddress region = new CellRangeAddress(positionV-1, positionV+nbCase-2, listP[4], listP[4]);
            sheet.addMergedRegion(region);
            cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
            cell.setCellStyle(cellStyle);
 
            fileOut = new FileOutputStream(path);
            wb.write(fileOut);
            fileOut.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } | 
Partager