
24/05/2006, 10:17
|
 | Colaborador | | Fecha de Ingreso: febrero-2001 Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 24 años, 2 meses Puntos: 535 | |
Probá esto a ver si sirve (es similar a lo que te pasé ayer para "el grid"):
Código:
miTabla = RS.GetRows
If Formato = "XLS" Then
'-----------------------------
' Generador de archivos XLS
'-----------------------------
Dim oExcel
Set oExcel = Server.CreateObject("OWC.Spreadsheet")
' Carga el nombre de los campos en la primer fila
iCol = 1
For Each Campo in RS.Fields
'objSpreadsheet.Cells(iRow, iCol).Value = objField.Name
oExcel.Cells(1,iCol).Value = Campo.Name
oExcel.Cells(1,iCol).Font.Bold = True
oExcel.Cells(1,iCol).Interior.Color = "SILVER"
iCol = iCol + 1
Next
' Carga los datos:
'Desde el primero hasta el último "registro"...
for Fila = 0 to UBound(miTabla,2)
'Desde el primero hasta el último "campo"...
for Columna = 0 to Ubound(miTabla, 1)
Celda = miTabla(Columna, Fila)
If IsNull(Celda) Then Celda = "s/d"
oExcel.Cells(Fila + 2,Columna + 1).Value = Celda
next
next
' Autoajusta el ancho de las columnas:
For iCol = 1 to Columna + 1
oExcel.Columns(iCol).AutoFitColumns
Next
' oExcel.ActiveSheet.Range("A:A").EntireColumn.Hidden = True
NameVariable = Request.Cookies("Usuario")("Nick") & "_" & Hour(Now()) & "-" & Minute(Now()) & "-" & Second(Now()) & ".xls"
Path=Server.MapPath("bco_datos/archivos_tmp/" & NameVariable)
oExcel.ActiveSheet.Export Path, 0
'-----------------------------
End if 'Formato XLS
' Borrar archivos del día anterior
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set Carpeta = FSO.GetFolder(Server.MapPath("bco_datos/archivos_tmp/"))
Set Archivos = Carpeta.Files
Hoy = Day(Now())
For Each Archivo in Archivos
Borrar = DateDiff("D", Day(Archivo.DateLastModified), Hoy)
If Borrar <> 0 Then
FSO.DeleteFile Server.MapPath("bco_datos/archivos_tmp/" & Archivo.name)
End If
Next
Set FSO = Nothing
Set Carpeta = Nothing
Set Archivos = Nothing
....
<a href="bco_datos/archivos_tmp/<% = NameVariable %>">descargar o abrir archivo xls</a>
Fijate en donde dice NameVariable, que será el nombre del archivo XLS (hay cosas de más que me dio fiaca de editar, así que revisalo antes de probarlo)
__________________ ...___... |