Guardar fichero excel con asp

jalbalat
17 de Diciembre del 2003
Hola,

Tengo creada una función que me genera a partir de los datos un fichero excel, pero al hacer el método Save ignora el parámetro que le paso para el path y el nombre y me lo guarda con el nombre que le da la gana (formado por números y letras)


¿A parte del Excel y el Web Component Server necesito tener instalado algo mas en el servidor?
NO encuentro diferencias entre un servidor u otro.

El código de mi función es el siguiente:

sub crear_document_excel(byval capcalera, byval dades, byval subcarpeta, byval document, byref missatge)
On Error resume next
missatge=""
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Application.Visible = True
Set ExcelBook = ExcelApp.Workbooks.Add


'Fulla excel amb la taula de resultats
x=1
y=1
if isarray(capcalera) then
for i=0 to ubound(capcalera)
ExcelBook.Worksheets(1).Cells(x, y).Font.Bold = true
ExcelBook.Worksheets(1).Cells(x, y).Value = capcalera(i)
y= y+1
next
else
missatge=Err.Description
end if
fila=1

if isarray(dades) then
for i=0 to ubound(dades,2)
if dades(0,i)<>"" then
fila = fila + 1
for j=0 to ubound(dades,1)
if dades(j,i)<>"" then
ExcelBook.Worksheets(1).Cells(i+2,j+1).Value=dades(j,i)
end if
next
end if
next

ExcelBook.Worksheets(1).name="Resultats"

'Calcul limit inferior de la fulla excel

col = ubound(dades,1) + 1
resto = col mod len(baseColumna)
entero = (col - resto)/len(baseColumna)
limitInferior = ""
if entero > 0 then
limitInferior=mid(baseColumna,entero,1)
end if
if resto > 0 then
limitInferior = limitInferior & mid(baseColumna,resto,1)
end if
limitInferior = limitInferior & cstr(fila)


'Fulla excel amb el gràfic
ExcelBook.Charts.Add
ExcelBook.ActiveChart.ChartType=xlBarClustered
ExcelBook.ActiveChart.SetSourceData ExcelBook.Worksheets(1).Range("B2:" & limitInferior),xlColumns

' 'Eliminar les series que hi ha per defecte fins a deixar només 1
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete
ExcelBook.ActiveChart.SeriesCollection(2).Delete

'Insertar titol al gràfic
ExcelBook.ActiveChart.HasTitle=true
ExcelBook.ActiveChart.SeriesCollection(1).Name="Gràfic"
'Eliminar legenda
ExcelBook.ActiveChart.HasLegend=False

'Insertar titol als eixos
ExcelBook.ActiveChart.Axes(xlCategory, xlPrimary).HasTitle = True
ExcelBook.ActiveChart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Alumnes"
ExcelBook.ActiveChart.Axes(xlValue, xlPrimary).HasTitle = True
ExcelBook.ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Resultats"
else
missatge=Err.Description
end if

if Err=0 then
path = obtenir_path
path = path & "Resultados" & subcarpeta & ""
path= path & "Res" & document
'response.write("<br>")
'response.write(path)
ExcelBook.SaveAS path

else
missatge=Err.Description
end if

ExcelApp.Application.Quit
Set ExcelBook = Nothing
Set ExcelApp = Nothing

end sub

Lo curisoso es que lo he probado en un servidor local con los mismos componentes de office instalado y el código me funciona perfectamente. Que me estoy dejando?

ah! es windows 2000 server y office 2000

Gracias por adelantada por vuestra ayuda.

Jose