Accedo a excel desde asp.net pero excel no cierra
Publicado por wakeup (29 intervenciones) el 06/10/2004 17:54:10
Estoy accediento a excel desde una aplicacacion asp.net pero no hay forma que una vez cierre el archivo excel desaparezca de la lista de procesos de windows el excel.exe.
He probado este codigo en un proyecto vb.net (no web) y el proceso excel.exe se cierra perfectamente, pero en asp.net no hay manera. ¿Alguien saber porque?
Este es el codigo...
Dim oExcel As New Excel.Application
Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oSheets As Excel.Sheets
oExcel.Visible = False
oExcel.UserControl = False
oBooks = oExcel.Workbooks
oBooks.Open("prueba.xls") 'Load colorful template with graph
oBook = oBooks.Item(1)
oSheets = oBook.Worksheets
oSheet = CType(oSheets.Item(1), Excel.Worksheet)
Label1.Text = oSheet.Cells(1, 1).Value
oBook.Close()
'Quit Excel and thoroughly deallocate everything
oExcel.Quit()
ReleaseComObject(oSheet)
ReleaseComObject(oSheets)
ReleaseComObject(oBook)
ReleaseComObject(oBooks)
ReleaseComObject(oExcel)
oExcel = Nothing
oBooks = Nothing
oBook = Nothing
oSheets = Nothing
oSheet = Nothing
System.GC.Collect()
He probado este codigo en un proyecto vb.net (no web) y el proceso excel.exe se cierra perfectamente, pero en asp.net no hay manera. ¿Alguien saber porque?
Este es el codigo...
Dim oExcel As New Excel.Application
Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oSheets As Excel.Sheets
oExcel.Visible = False
oExcel.UserControl = False
oBooks = oExcel.Workbooks
oBooks.Open("prueba.xls") 'Load colorful template with graph
oBook = oBooks.Item(1)
oSheets = oBook.Worksheets
oSheet = CType(oSheets.Item(1), Excel.Worksheet)
Label1.Text = oSheet.Cells(1, 1).Value
oBook.Close()
'Quit Excel and thoroughly deallocate everything
oExcel.Quit()
ReleaseComObject(oSheet)
ReleaseComObject(oSheets)
ReleaseComObject(oBook)
ReleaseComObject(oBooks)
ReleaseComObject(oExcel)
oExcel = Nothing
oBooks = Nothing
oBook = Nothing
oSheets = Nothing
oSheet = Nothing
System.GC.Collect()
Valora esta pregunta
0