Bonjour
J'ai besoin de retranscrire sous excel un planning de réservations généré sur un support web avec des couleurs html.
Afin d'être aussi fidèle que possible j'aimerais aussi retranscrire les couleurs utilisées.
J'ai testé quelques bouts de codes comme ci dessous sans résultat probant.
Auriez vous une idée
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public static short couleur1 (HSSFWorkbook workbook, String color){ //couleur html du type 'A7A37E' int r = Integer.parseInt( color.substring(0, 2), 16); int v = Integer.parseInt( color.substring(2, 4), 16); int b = Integer.parseInt( color.substring(4, 6), 16); HSSFPalette palette = workbook.getCustomPalette(); HSSFColor hssfColor = null; short index; if(indexcolor.indexOf(color)==-1) {//couleur non initialisée indexcolor.add(color); // +64 pour être hors palette prédéfinie d'excel index = (short)(indexcolor.indexOf(color)+64); try { hssfColor= palette.findColor((byte)r, (byte)v, (byte)b); if (hssfColor == null ){ palette.setColorAtIndex(index, (byte)r, (byte)v, (byte)b); //hssfColor = palette.getColor(index); } } catch (Exception e) {e.printStackTrace();} } else {//couleur initialisée index = (short)(indexcolor.indexOf(color)+64);} return index; }
Merci
Partager