Ciao a tutti,
non vorrei che questa domanda fosse già stata posta, ma non mi funziona la ricerca e non posso scoprirlo.
Il mio problema è il seguente:
voglio creare un file .xls salvato su disco, che prenda i dati da un database in base a dei criteri da me espressi nella form di "creazione".
Ho già trovato un modo x scrivere, diciamo, il file, e lo visualizzo a video in effetti con lo stile di un file excel, ma non so come fare x salvare direttamente quello che vedo sull'hard disk. Questo mi servirebbe perchè in automatico dovrei allegare questo file ad una mail da spedire (a questo ci penserò dopo...).

Ecco il mio codice:

codice:
<%@ Language=VBScript %>
<%
m_user = Session("m_user")
m_numero = Session("m_numero")
m_admin = Session("m_admin")
m_nome = Session("m_nome")
m_cognome = Session("m_cognome")

matricola = (m_cognome + " " + m_nome)
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE>Elenco attività</title>
<script language="javascript">
<!--
function op(Url){
		window.open (Url);
	}
function opw(Url,Desc,Wi,He,Scroll){
		window.open(Url,Desc,"resize=0,scrollbars="+Scroll+",width="+Wi+",height="+He);
		}
//-->
</script>
</HEAD>
<body bgcolor="#e9e9e9" >
<DIV align=center>
<TABLE border=1 cellPadding=0 cellSpacing=0 width="100%" style="HEIGHT: 49px; WIDTH: 423px" align=left>
	<TR>
		<td>Giorni:</td>
		<td>Progetto:</td>
		<td>Attività:</td>
		<td>Ore:</td>
		<td>Tipo:</td>
	</TR>
<%  
'Restituisce una stringa che contiene il mese in forma esteso
Function MeseEstesoSito (Mese)
	Select Case Mese
	Case 1
		MeseEstesoSito = "Gennaio"
	Case 2
		MeseEstesoSito = "Febbraio"
	Case 3
		MeseEstesoSito = "Marzo"
	Case 4
		MeseEstesoSito = "Aprile"
	Case 5
		MeseEstesoSito = "Maggio"
	Case 6
		MeseEstesoSito = "Giugno"
	Case 7
		MeseEstesoSito = "Luglio"
	Case 8
		MeseEstesoSito = "Agosto"
	Case 9
		MeseEstesoSito = "Settembre"
	Case 10
		MeseEstesoSito = "Ottobre"
	Case 11
		MeseEstesoSito = "Novembre"
	Case 12
		MeseEstesoSito = "Dicembre"
	End Select
End Function


	Invia = Request.Form("Invia")
	a_m_numero = Request.Form ("a_m_numero")
	datapart = Request.Form ("datapart")
	datapart2= Request.Form ("datapart2")

'----------------------------------------
'Connessione al DataBase e select per ottenere la descrizione della domanda'	
'----------------------------------------
		
		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQL = "SELECT a_nrora,p_desc,a_data,a_note,a_cod_tipo,m_cognome FROM matricola,Attivita,Progetti,tipo where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"' and p_codice= a_p_codice  and a_cod_tipo = cod_tipo and m_numero= a_m_numero order by a_data"
		Set RS = Conn.Execute(SQL)
		
		if  rs.EOF then 
	     Response.Write ("Non sono state inserite le informazioni per visualizzare l'elenco delle ore ")
		else
	    rs.MoveFirst 
		end if 
%>
	
<%
'-----------------------------------------------
'Visualizzazione della select
'------------------------------------------------

%>
    FOCUS INFORMATICA S.a.S
    

    MATRICOLA: <%=Response.Write (A_M_NUMERO)%> COGNOME: <%=rs("m_cognome")%>
    
	
Mese:<%=Response.Write (MeseEstesoSito(Month(datapart)))%>[b]
<%
Do While Not RS.EOF
	Response.ContentType = "APPLICATION/VND.MS-EXCEL"
%>
	<tr>
		<TD VALIGN="top" bgcolor="#ffffff" width="10%"><%=RS("a_data")%></TD> 
		<TD VALIGN="top" bgcolor="#ffffff" width="35%"><%=RS("p_desc")%></TD> 
		<TD VALIGN="top" bgcolor="#ffffff" width="35%"><%=RS("a_note")%></TD> 
		<TD VALIGN="top" bgcolor="#ffffff" width="10%"><%=RS("a_nrora")%></TD>   	
		<TD VALIGN="top" bgcolor="#ffffff" width="10%"><%=RS("a_cod_tipo")%></TD>   	
	</tr>
    <%
		RS.MoveNext
		Loop
		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQLrs = "SELECT sum(a_nrora) oren FROM Attivita,Progetti where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"' and p_codice= a_p_codice and a_cod_tipo ='N'"
		Set RS = Conn.Execute(SQLrs)
		
	%>
</TABLE>		 
	<TABLE border=1 cellPadding=0 cellSpacing=0 width="425" style="HEIGHT: 49px" align=center>	
	

	<TR>	
		<td valign=center width="388" align=left>Totale Ore Normali:</td>
		<TD bgcolor="#ffffff" width="31"  align=right><%=RS("oren")%></TD> 
	</TR>
	    </TABLE>
<%
	RS.Close
	Conn.Close
	Set RS = nothing
	Set Conn= nothing
	
%>

<%
		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQLrs = "SELECT sum(a_nrora) orep FROM Attivita,Progetti where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"' and p_codice= a_p_codice and a_cod_tipo ='P'"
		Set RS = Conn.Execute(SQLrs)
		
%>
<TABLE border=1 cellPadding=0 cellSpacing=0 width="425" style="HEIGHT: 49px" align=center>	
    	
	

    
	<TR>	
		<td width="388" align=left>Totale Ore Permessi:</td>
		<TD bgcolor="#ffffff" width="31" align=right><%=RS("orep")%></TD> 
	</TR>
	    </TABLE>
<%
	RS.Close
	Conn.Close
	Set RS = nothing
	Set Conn= nothing
	
%>

<%
		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQLrs = "SELECT sum(a_nrora) oref FROM Attivita,Progetti where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"' and p_codice= a_p_codice and a_cod_tipo ='F'"
		Set RS = Conn.Execute(SQLrs)
		
%>
<TABLE border=1 cellPadding=0 cellSpacing=0 width="425" style="HEIGHT: 49px" align=center>	
    	
	

    
	<TR>	
		<td width="388" align=left>Totale Ore Ferie:</td>
		<TD bgcolor="#ffffff" width="31" align=right><%=RS("oref")%></TD> 
	</TR>
	    </TABLE>	    
<%
	RS.Close
	Conn.Close
	Set RS = nothing
	Set Conn= nothing
	
%>	   	    	  

<%
		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQLrs = "SELECT sum(a_nrora) orec FROM Attivita,Progetti where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"' and p_codice= a_p_codice and a_cod_tipo ='C'"
		Set RS = Conn.Execute(SQLrs)
		
%>
<TABLE border=1 cellPadding=0 cellSpacing=0 width="425" style="HEIGHT: 49px" align=center>	
    	
	

    
	<TR>	
		<td width="388" align=left><FONT width="90%">Totale
          Ore Corso:</FONT></td>
		<TD VALIGN=center bgcolor="#ffffff" width="31" align=right><%=RS("orec")%></TD> 
	</TR>
	    </TABLE>	    
<%
	RS.Close
	Conn.Close
	Set RS = nothing
	Set Conn= nothing
	
%>

<%
		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQLrs = "SELECT sum(a_nrora) oret FROM Attivita,Progetti where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"'  and p_codice= a_p_codice and a_cod_tipo ='T'"
		Set RS = Conn.Execute(SQLrs)
		
%>
<TABLE border=1 cellPadding=0 cellSpacing=0 width="425" style="HEIGHT: 49px" align=center>	
    	
	

    
	<TR>	
		<td width="388" align=left><FONT width="90%">Totale Ore Trasferta:</FONT></td>
		<TD VALIGN=center bgcolor="#ffffff" width="31" align=right><%=RS("oret")%></TD> 
	</TR>
	    </TABLE>	    
<%
	RS.Close
	Conn.Close
	Set RS = nothing
	Set Conn= nothing
	
		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQLrs = "SELECT sum(a_nrora) oret FROM Attivita,Progetti where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"'  and p_codice= a_p_codice and a_cod_tipo ='V'"
		Set RS = Conn.Execute(SQLrs)
		
%>
<TABLE border=1 cellPadding=0 cellSpacing=0 width="425" style="HEIGHT: 49px" align=center>	
    	
	

    
	<TR>	
		<td width="388" align=left><FONT width="90%">Totale Ore Festa Nazionale:</FONT></td>
		<TD VALIGN=center bgcolor="#ffffff" width="31" align=right><%=RS("oret")%></TD> 
	</TR>
	    </TABLE>	    
<%
	RS.Close
	Conn.Close
	Set RS = nothing
	Set Conn= nothing
	

		Set Conn = Server.CreateObject("ADODB.Connection")
		Set RS = Server.CreateObject("ADODB.Recordset")
		Conn.Open "DSN=FocusIntra"
				
		SQLrs = "SELECT sum(a_nrora) oretot FROM Attivita,Progetti where a_m_numero = '"& a_m_numero &"' and a_data between '"& datapart &"' and '"& datapart2 &"'  and p_codice= a_p_codice "
		Set RS = Conn.Execute(SQLrs)
		
%>
<TABLE border=1 cellPadding=0 cellSpacing=0 width="425" style="HEIGHT: 49px" align=center>	
    	
	

    
	<TR>	
		<td width="388">TOTALE ORE:</td>
		<TD VALIGN=center bgcolor="#ffffff" width="31" align=right><%=RS("oretot")%></TD> 
	</TR>
	    </TABLE>
<P align=center><INPUT id=button2 name=button2 type=button value=Excel onclick="op('excel.asp?a_m_numero=<%Response.Write (a_m_numero)%>&amp;datapart=<%Response.Write(datapart)%>&amp;datapart2=<%=Response.Write(datapart2)%> ')"></P>
<%
	RS.Close
	Conn.Close
	Set RS = nothing
	Set Conn= nothing
		
%></FORM></DIV>
</body>
Grazie a tutti dell'aiuto