Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/10/2005, 20:28
Avatar de goncafa
goncafa
 
Fecha de Ingreso: julio-2002
Ubicación: Santiago
Mensajes: 1.211
Antigüedad: 24 años, 2 meses
Puntos: 10
Código PHP:
<%@page import="java.io.*"%>
<%@
page contentType="application/vnd.ms-excel"%>
<%
    
InputStream in = null;
    
ServletOutputStream bufferSalida = null;
    
    
String nombre = "nombre.xls";
        
String path = "RUTA_AL_XLS";

    
response.setHeader("Content-Disposition","attachment; filename=\""+ nombre + "\"");

    try {
        
in = new FileInputStream(path);
        
bufferSalida = response.getOutputStream();

        
//se transfieren los bytes
        
byte[] buf = new byte[1024];
        
int len;
            while ((
len = in.read(buf)) > 0) {
                
bufferSalida.write(buf, 0, len);
            }

        
//vaciamos el buffer de salida y se envia el resultado
        
in.close();
        
bufferSalida.flush();
        
bufferSalida.close();
    } catch(
Exception e) {
        
//no hagamos nada
    
}
%> 
Saludos
__________________
se despide hasta la proxima
Gonzalo Castillo