Not been able to dispose the Excel Headers
Hi All,
am exporting a huge dataset to Excel.While doing this i have created mutiple excel sheet by segregating the dataset.My problem is that Headers of the First Excel sheet getting appended everytime a new excel sheet is created(not been able to dispose the Headers).I have use :-
excel.Quit()
excel = Nothing
Marshal.ReleaseComObject(excel)
System.GC.Collect()
but did not work.
also use the following function ...still no output:-
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
Public Function TerminateExcel()
Dim ClassName As String = "XLMain"
Dim WindowHandle As Int32
Dim ReturnVal As Int32
Const WM_QUIT = &H12
Do
WindowHandle = FindWindow(ClassName, Nothing)
If WindowHandle Then
ReturnVal = PostMessage(WindowHandle, WM_QUIT, 0, 0)
End If
Loop Until WindowHandle = 0
End Function
Please help to resolve this problem.
|