Bonjour,

je travaille avec une méthode rédigée par un tiers qui fonctionne très bien pour exporter des données vers un template excel.
Cependant, bien que les formats soient définis dans le template, il me faut "convertir" les colonnes une à une afin que le format soit évalué (lorsqu'on tape par ex une date directement dans excel, l'évaluation est immédiate; pas dans mon cas depuis mon code java).
Est-ce que l'un(e) d'entre vous aurait connaissance d'une méthode qui permettrait à ma méthode de forcer cette conversion lors du remplissage de mon template?

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    /**
     * Get the excel data.
     * 
     * @param key key
     * @param exportList contact list
     * @param templateFilePath template file path
     * @return the excel data
     * @throws NotSerializableException thrown if the input list of objects to be exported do not implement java.io.Serializable
     */
    public final ByteArrayOutputStream getExcelData(String key, String templateFilePath, List<Serializable> exportList) throws NotSerializableException {
 
        if(!(exportList instanceof java.io.Serializable) ){
            throw new NotSerializableException(exportList.getClass().getName());
        }
 
        Map<String, List<Serializable>> beans = new HashMap<String, List<Serializable>>();
        beans.put(key, exportList);
 
        InputStream templateXsl = ExportService.class.getClassLoader().getResourceAsStream(templateFilePath);
        if (templateXsl == null) {
            return null;
        }
 
        return getExcelData(beans, templateXsl);
    }
 
    /**
     * Get the excel data.
     * 
     * @param beans object that will be processed : must implement java.io.Serializable
     * @param templateXsl template xsl
     * @return the excel data
     * @throws NotSerializableException 
     */
    private final ByteArrayOutputStream getExcelData(Map<String, List<Serializable>> beans, InputStream templateXsl) throws NotSerializableException {
        if(!(beans instanceof java.io.Serializable) ){
            throw new NotSerializableException(beans.getClass().getName());
        }
 
        XLSTransformer transformer = new XLSTransformer();
 
        HSSFWorkbook temp = transformer.transformXLS(templateXsl, beans);
 
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
        try {
            temp.write(bos);
        } catch (Exception e) {
            logger.error("Error while exporting the excel data", e);
        } 
 
        return bos;
    }
Merci d'avance de votre intéret, et éventuellement de vos suggestions / remarques