<%
'comprobamos si introducimos un titulo
u_title=Request.Form("u_title")
If u_title = "" Then
%>
<html>
<body bgcolor="#FFFFFF">
<!-- Formulario - Solo será mostrado si no ingrasamos un titulo -->
<form method="POST" action="<%= request.servervariables("script_name") %>">
Titulo del documento<br>
<Input Type="text" name="u_title" size="35">
<br><br>
Celda 1<br>
<textarea rows="2" name="u_cell1" cols="35"></textarea>
<br><br>
Celda2<br>
<textarea rows="2" name="u_cell2" cols="35"></textarea>
<Input Type="submit" value="Submit" ></p>
</form>
<%
Else
' Si se introdujo un titulo
' Obtenemos todos los valores
u_title=Request.Form("u_title")
u_cell1=Request.Form("u_cell1")
u_cell2=Request.Form("u_cell2")
' Empezamos a crear el nombre del archivo excel
g_filename=Replace(u_title," ","_")
Set fso = CreateObject("scripting.filesystemobject")
' Creamos el nombre mediante fechas
Set act = fso.CreateTextFile(Server.MapPath(""&g_filename & "-"& Month(Date())& Day(Date())& Year(Date()) &".xls"), True)
' creamos el archivo
act.WriteLine "<html xmlns:x=""urn:schemas-microsoft-com:office:excel"">"
act.WriteLine "<head>"
act.WriteLine "<!--[if gte mso 9]><xml>"
act.WriteLine "<x:ExcelWorkbook>"
act.WriteLine "<x:ExcelWorksheets>"
act.WriteLine "<x:ExcelWorksheet>"
act.WriteLine "<x:Name>"& u_title &"</x:Name>"
act.WriteLine "<x:WorksheetOptions>"
act.WriteLine "<x:Print>"
act.WriteLine "<x:ValidPrinterInfo/>"
act.WriteLine "</x:Print>"
act.WriteLine "</x:WorksheetOptions>"
act.WriteLine "</x:ExcelWorksheet>"
act.WriteLine "</x:ExcelWorksheets>"
act.WriteLine "</x:ExcelWorkbook>"
act.WriteLine "</xml>"
act.WriteLine "<![endif]--> "
act.WriteLine "</head>"
act.WriteLine "<body>"
act.WriteLine "<table>"
act.WriteLine "<tr>"
act.WriteLine "<td>"
act.WriteLine u_cell1
act.WriteLine "</td>"
act.WriteLine "<td>"
act.WriteLine u_cell2
act.WriteLine "</td>"
act.WriteLine "</tr>"
act.WriteLine "</table>"
act.WriteLine "</body>"
act.WriteLine "</html>"
act.close
%>
Tu archivo excel se creó correctamente. Pulsa <a href="<%= g_filename &"-"& month(date())& day(date())& year(date()) %>.xls">aqui</a>
para verlo.
<%
End If
%>
</body>
</html>