Good morning,
I have the following code:
Everything works perfectly until I want to delete the file. How on earth do I close the file so I can delete it? I can't seem to find the way to do it. :(
Thank you VERY much for this amazing work you've done, by the way.
I have the following code:
Private Sub Btn_export_Click() Handles Btn_export.Click
Dim book As XLWorkbook = New XLWorkbook(XLEventTracking.Disabled)
Dim table As System.Data.DataTable
table = DGV_preview.DataSource
book.AddWorksheet(table, "Result")
book.SaveAs("visitation.xlsx")
' HERE BE SOME E-MAIL SENDING
book.Worksheets(0).Dispose()
book.Dispose()
table.Dispose()
File.Delete("visitation.xlsx")
End Sub
Basically I want to create an Excel file, transfer a DataTable into it, Save the file, e-mail it and then delete the file. Everything works perfectly until I want to delete the file. How on earth do I close the file so I can delete it? I can't seem to find the way to do it. :(
Thank you VERY much for this amazing work you've done, by the way.