I have find out solution for this type of problem.
After 2 days hard work & RND I got Success to Solve this problem.
But the problem is this code will RUN only in
VB.net not In ASP.net
I m still Searching solutions for that.
I m uploading My code. Hope It will give help to some one who need to perform such type of functionality.
Enjoy.....
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
Developed By : Jatin Patel
contact No : 9819376788
VB.net Code
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
Declarations :
Imports Excel
Imports System
Imports System.Reflection
Imports System.IO
Imports System.Runtime.InteropServices
Public Function OpenExcel(ByVal Interact As Boolean) As Excel.ApplicationClass
Dim App As Excel.ApplicationClass
App = New Excel.ApplicationClass
App.DisplayAlerts = Interact
App.Interactive = Interact
App.Visible = Interact
' uniquely mark this instance of Excel
App.Caption = System.Guid.NewGuid.ToString.ToUpper
Return App
End Function
Public Sub Main1()
Dim myExcel As Excel.ApplicationClass
Dim sh As Excel.Worksheet
myExcel = OpenExcel(True)
sh = myExcel.Workbooks.Add().ActiveSheet
sh.Range("A1:A1").Value = "Hello World"
Console.WriteLine("... hit ENTER to close:")
Console.ReadLine()
CloseExcel(myExcel, True)
Console.WriteLine("... hit ENTER to exit:")
Console.ReadLine()
End Sub
Private Sub CloseExcel(ByVal App As Excel.ApplicationClass, ByVal bl As Boolean)
If Not App.Workbooks Is Nothing Then
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
For Each wb In App.Workbooks
For Each ws In wb.Worksheets
System.Runtime.InteropServices.Marshal.ReleaseComO bject(ws)
ws = Nothing
Next
wb.Close(False)
System.Runtime.InteropServices.Marshal.ReleaseComO bject(wb)
wb = Nothing
Next
App.Workbooks.Close()
End If
App.DisplayAlerts = False
App.Quit()
GC.Collect()
GC.WaitForPendingFinalizers()
KillAllExcels()
End Sub
Sub KillAllExcels()
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXC EL")
proc.Kill()
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Main1()
End Sub
************************************************** *************
Hope it will Help You.. If you find some solution to run this code in ASP.net then please contact me.
Jatin s. Patel