Hallo,
ich habe ein Problem bei einem Export von Visual Studio nach Excel.
Sobald ich mehr als 3 Zellen nach Excel exportiere (ab Zeile 17 bleibt beim Beenden
der Excel Prozess im Taskmanager hängen. Er geht zwar schon weg
wenn ich die Form schließe. Aber das stört mich ein wenig.
Hab auch schon einen Timer eingebunden, hat aber nix geholfen.
Vielleicht kann mir jemand helfen.
Was mach ich falsch???
Gruß Michael
ich habe ein Problem bei einem Export von Visual Studio nach Excel.
Sobald ich mehr als 3 Zellen nach Excel exportiere (ab Zeile 17 bleibt beim Beenden
der Excel Prozess im Taskmanager hängen. Er geht zwar schon weg
wenn ich die Form schließe. Aber das stört mich ein wenig.
Hab auch schon einen Timer eingebunden, hat aber nix geholfen.
Vielleicht kann mir jemand helfen.
Was mach ich falsch???
Gruß Michael
VB.NET-Quellcode
- Sub excel_export()
- Dim XLSApp As New Excel.Application
- Dim XLSWS As New Excel.Worksheet
- Dim path As String = "D:\Kalkulationsblatt.xlsx"
- XLSApp.Workbooks.Open(path) : path = Nothing
- XLSApp.Visible = True
- 'Daten nach Excel schreiben
- XLSWS = XLSApp.Sheets(1)
- With XLSWS
- .Select()
- .Visible = True
- .Cells(4, 3).value = FRM_VA_KALK.TXT_Kopf_Kunde.Text.ToString
- .Cells(6, 3).value = FRM_VA_KALK.TXT_Kopf_Ansprechpartner.Text.ToString
- .Cells(8, 3).value = FRM_VA_KALK.TXT_Kopf_Adresse.Text.ToString
- .
- .
- .
- End With
- XLSWS = Nothing
- 'Excel Speichern und beenden
- With XLSApp
- .ActiveWorkbook.Save()
- .DisplayAlerts = False
- .Quit()
- End With
- 'Prozess beenden
- System.Runtime.InteropServices.Marshal.ReleaseComObject(XLSWS)
- XLSWS = Nothing
- System.Runtime.InteropServices.Marshal.ReleaseComObject(XLSApp)
- XLSApp = Nothing
- GC.Collect()
- GC.WaitForPendingFinalizers()
- End Sub