2009-05-21 4 views
1

Voici le code, il ne montre pas le fichier .csv:Comment afficher le contenu Excel de Struts portlet sur Websphere Portal

public class ForwardAction extends MultiAction { 
private static final String FILE_ERROR = "<h3><center>INVALID FILE</center></h3>"; 
    public ActionForward doVizualizare(ActionMapping mapping, ActionForm form, 
     HttpServletRequest request, HttpServletResponse response) 
     throws Exception { 

    StringBuffer sb = new StringBuffer(); 
    sb.append("Name,Email,Phone"); 
    sb.append(System.getProperty("line.separator")); 
    sb.append("Naveen,[email protected],111-111-111"); 

    OutputStream resOut = response.getOutputStream(); 
    try { 
     response.setContentType("application/octet-stream"); 
     response.setHeader("Content-Disposition", "attachment; filename=\"a.csv\""); 
     resOut.write(sb.toString().getBytes()); 
    } catch (Exception e) { 
     resOut.write(FILE_ERROR.getBytes()); 
    } 
    return null; 
} 
} 

Répondre

0

près & affleurant le flux de sortie.

également vérifier si la méthode doVizualizare est appelée

Questions connexes