469,271 Members | 1,452 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

killing Excel instance through ASP.NET

I'm opening an Excel file using ASP.NET, but Excel process remains it is not killed, I tried killing it by using Quit() that is also not working, if anybody have any solution for this please help me out.
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 19 '05 #1
3 1856
"kunal" <ku***************@patni.com> wrote in message
news:uo**************@TK2MSFTNGP14.phx.gbl...
I'm opening an Excel file using ASP.NET, but Excel process remains it is
not killed, I tried killing
it by using Quit() that is also not working, if anybody have any solution
for this please help me out.


1) Are you instantiating Excel server-side in VB.NET / C# etc, or
client-side using JavaScript / VBScript and ActiveX / WSH?

2) What version of Excel?

3) Please post the code you use to instantiate Excel and open the
workbook(s), plus the code you're using to (try to) kill it.
Nov 19 '05 #2
I'm using C# to instantiate Excel on server side.
Excel version is 9.0
Below is the code written for Excel.
Excel.ApplicationClass oXL = new Excel.ApplicationClass();
oXL.WindowState=Excel.XlWindowState.xlMaximized;
oXL.ShowWindowsInTaskbar =true;

//oXL.WindowActivate +=Microsoft.Office.Interop.Excel.AppEvents_WindowA ctivateEventHandler;
//oXL.Windows =Microsoft.Office.Interop.Excel.Windows;
oXL.EnableEvents=true;
oXL.Visible=true;

//oXL.ShowStartupDialog=true;
//oXL.DisplayExcel4Menus = true;
int hwndExcel;
oXL.Visible=true;
oXL.WindowState=Excel.XlWindowState.xlMaximized;
oXL.Caption = "Some Caption For Excel Window";
hwndExcel = MyApi.FindWindow("XLMAIN",oXL.Caption);
string Excelstr1 = hwndExcel.ToString();

System.Diagnostics.Process [] processArr2=System.Diagnostics.Process.GetProcesse sByName("Excel");
int process2cnt,processid=100000;
for(process2cnt=0;process2cnt<processArr2.Length;p rocess2cnt++)
{
if(processArr2[process2cnt].MainWindowHandle.ToString()==Excelstr1)
{
processid=processArr2[process2cnt].Id;
//processArr2[process2cnt].Kill();
break;
}
}
// Form1 oform1 =new Form1();
//pid=oform1.GetProcessID(oXL);
//ewclass oewclass =new ewclass();
//pid=oewclass.GetProcessID(oXL);

if(pid!=100000)
//{
Process.GetProcessById(pid).Kill();
}
}

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 19 '05 #3
It's not recommended that you create Excel isntances from a server process
like this. Excel wasn't designed for this. However, I do go over the
techniques involved in this article in case you feel like breaking the
rules. As you'll see, killing the Excel process requires a lot of code.
The article also covers other techniques that are less likely to cause
problems.
http://steveorr.net/Articles/ExcelExport.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"kunal" <ku***************@patni.com> wrote in message
news:uo**************@TK2MSFTNGP14.phx.gbl...
I'm opening an Excel file using ASP.NET, but Excel process remains it is
not killed, I tried killing it by using Quit() that is also not working,
if anybody have any solution for this please help me out.
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by net guest via DotNetMonster.com | last post: by
2 posts views Thread by tony.newsgrps | last post: by
9 posts views Thread by Doug Glancy | last post: by
5 posts views Thread by =?Utf-8?B?QmFyZW4=?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.