hi
i have some code to generate a excel workbook with a sheet filled with some informations.
Instead of just save the excel file locally on the server, i want the user to save in on theres owns computer.
My code to save the file:
Dim fileName As String = Server.MapPath("~/temp/" & Guid.NewGuid().ToString() & ".xlsx") Console.WriteLine(fileName) _excel.ActiveWorkbook.SaveAs(fileName) Response.Clear() Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition", "attachment;filename=Konto.xslx") Response.WriteFile(fileName) Response.End() Catch ex As Exception ClientScript.RegisterStartupScript(Me.GetType(), "myalert", "alert('Exporting Failed " & ex.Message & "');", True) Finally wBook.Close() wSheet = Nothing wBook = Nothing _excel.Quit() _excel = Nothing
the code failed with this error:
Path\temp\c8ccf73c-76af-4b22-930e-6ca013856de8.xlsx' because it is being used by another process.
If i try to call wBook.Close after SaveAs method, then i got a new error. "Thread was aborted"..