Bonjour,

Je voudrai convertir un tableau csv vers un tableau xls. Y-a-t-il une api java qui me permet de faire cette conversion?
J'ai trouvé jxl et j'ai essayé le code ci dessous :

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import java.io.*;
import jxl.*;
import java.util.*;
 
public class ConvertCSV {
 
	public static void main(String[] args) 
	  {
	    try
	    {
	      //File to store data in form of CSV
	      File f = new File("test.xls");
 
	      OutputStream os = (OutputStream)new FileOutputStream(f);
	      String encoding = "UTF8";
	      OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
	      BufferedWriter bw = new BufferedWriter(osw);
 
	      //Excel document to be imported
	      String filename = "test.csv";
	      WorkbookSettings ws = new WorkbookSettings();
	      ws.setLocale(new Locale("en", "EN"));
	      Workbook w = Workbook.getWorkbook(new File(filename),ws);
 
	      // Gets the sheets from workbook
	      for (int sheet = 0; sheet < w.getNumberOfSheets(); sheet++)
	      {
	        Sheet s = w.getSheet(sheet);
 
	        bw.write(s.getName());
	        bw.newLine();
 
	        Cell[] row = null;
 
	        // Gets the cells from sheet
	        for (int i = 0 ; i < s.getRows() ; i++)
	        {
	          row = s.getRow(i);
 
	          if (row.length > 0)
	          {
	            bw.write(row[0].getContents());
	            for (int j = 1; j < row.length; j++)
	            {
	              bw.write(',');
	              bw.write(row[j].getContents());
	            }
	          }
	          bw.newLine();
	        }
	      }
	      bw.flush();
	      bw.close();
	    }
	    catch (UnsupportedEncodingException e)
	    {
	      System.err.println(e.toString());
	    }
	    catch (IOException e)
	    {
	      System.err.println(e.toString());
	    }
	    catch (Exception e)
	    {
	      System.err.println(e.toString());
	    }
	  }
 
}
et j'ai eu ce message d'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
jxl.read.biff.BiffException: Unable to recognize OLE stream
Merci d'avance.