bonjour,

sur une jsp j'ai crée un bouton excel qui fait appel à une servlet d'extraction ds un fichier excel:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 //bouton xls
<p align="center"><DIV id="excelButton" style="cursor:hand"><IMG src="<%=request.getContextPath()%>/images/excel.gif" onClick="openExcel();"></IMG></DIV></p
 
//fcn openExcel qui fait appel à la servlet Servtemp
    function openExcel()
    {
         open('/taxis/Servtemp?actionPage=10&displayFormat=EXCEL;
    }
Enfin, dans ma servlet je fais les instructions suivantes:


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
                 StringBuffer sbFileName=new StringBuffer();
                sbFileName.append("/pub/xls/");
                String userId=null;
                HttpSession session = request.getSession(false);                
                String fileName=getServletContext().getRealPath(sbFileName.toString());
                File excelFile=new File(fileName);
                FileWriter excelFileWriter=new FileWriter(excelFile);                
                Vector result = new Vector();
                Vector ligneTmp = new Vector();
                Personne p = new Personne();
                result=p.getListPersonnes();
 
                for (int i=0;i<result.size();i++){
                    //Génération String
                    ligneTmp = (Vector)result.elementAt(i);
                    htmlFlux=(String)ligneTmp.elementAt(0);
                    htmlFlux+=";";
                    htmlFlux+=(String)ligneTmp.elementAt(1);
                    htmlFlux+=";";
                    htmlFlux+=(String)ligneTmp.elementAt(2);
                    htmlFlux+=";";                
                    htmlFlux+=(String)ligneTmp.elementAt(3);
                    htmlFlux+=";";
                    htmlFlux+=(String)ligneTmp.elementAt(4);
                    htmlFlux+=";";                    
                    htmlFlux+=(String)ligneTmp.elementAt(5);
                    htmlFlux+=";";
                    htmlFlux+=(String)ligneTmp.elementAt(6);                                    
 
                }
                excelFileWriter.write(htmlFlux);
                excelFileWriter.flush();
                excelFileWriter.close();
lorsque je compile je n'ai aucun pb mais qd j'appuie sur le bouton, mon fichier excel ne s'ouvre pas!

qqn peut m'aider?