Ho risolto il problema, qui di seguito c'è la riga di codice.
Ricordate che ho utilizzato i PIAs dei VSTO:
x_ws = x_wb.Worksheets.Item("Output")
x_ws.Activate()
x_app.Application.DisplayAlerts = False
x_ws.SaveAs(Me.MapPath("Elaborazione") & "\" & CStr(Session.SessionID) & ".html", Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml)
x_app.Application.Quit()
Ora ho un altro problema: quando cerco di eliminare l'oggetto Excel.Application, mi ritrovo Excel.EXE ancora in memoria. come devo fare? Di seguito il codice che uso in chiusura:
xls_app.Application.DisplayAlerts = False
xls_wb.Save()
xls_app.Application.Quit()
While (System.Runtime.InteropServices.Marshal.ReleaseComObject(xls_rg) > 0)
End While
While (System.Runtime.InteropServices.Marshal.ReleaseComObject(xls_ws) > 0)
End While
While (System.Runtime.InteropServices.Marshal.ReleaseComObject(xls_wb) > 0)
End While
While (System.Runtime.InteropServices.Marshal.ReleaseComObject(xls_app) > 0)
End While
GC.Collect()
GC.WaitForPendingFinalizers()