s'il vous plait j'ai problème avec l'ouverture de fichiers, je travail avec Struts1,j'ai testé le code suivant qui marche tres bien:
mon problème quand je l'ai intégré dans mon action , ça marche plus
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 public class OpenF { public static void main(String[] sArgs) throws SQLException, IOException{ if ( Desktop.isDesktopSupported() ) { // On récupère l'instance du desktop : Desktop desktop = Desktop.getDesktop(); // On vérifie que la fonction open est bien supportée : if (desktop.isSupported(Desktop.Action.OPEN)) { // Et on lance l'application associé au fichier pour l'ouvrir : desktop.open(new File("D:\\exemple2.xls")); } } } }
s'il y a une autre solution , j'attend vos reponses
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 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ExportForm ef=(ExportForm)form; Operation op=new Operation(); DataH d; String url="D:\\excel\\"+ef.getFichier()+".xls"; if ( Desktop.isDesktopSupported() ) { // On récupère l'instance du desktop : Desktop desktop = Desktop.getDesktop(); // On vérifie que la fonction open est bien supportée : if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File(url)); } } return mapping.findForward(SUCCESS); }
Partager