473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 1991
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
0
by: net guest via DotNetMonster.com | last post by:
Hi, i am facing a lot of problems in killing the orphan excel instances. I approached one method like killing the Excel Orphan with processID. I am getting all the Processess that are running...
5
by: Wenke Ji | last post by:
Hi I open a Excel workbook using below API: Set ExcelServer = CreateObject("EXCEL.Application") Set TargetWorkbook = ExcelServer.Workbooks.Open (CurrentBook) Befor the programm exit , I use...
2
by: tony.newsgrps | last post by:
Hi there, I'm trying to understand the impact of killing a process that owns a system mutex (used to ensure there is only 1 instance of my program running) Here is my code pretty much: try...
16
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
5
by: =?Utf-8?B?QmFyZW4=?= | last post by:
Hi! All, I am using a ASP.NEt application, wherein i am automating Execl object. I am not able to destroy the instance, eve if I write this to destroy the instance of Excel. Please find the ...
0
by: ravindarjobs | last post by:
dear friends, i am using ms access 2003. i wanted to export data from access table to excel table. so i have followed this Dim db As Database Dim ea As Excel.Application Dim rs As...
24
rauty
by: rauty | last post by:
Hi all, I'm trying to access the most recent instance of Excel so I can paste data. What works for me is if Excel isn't already opened, I open it and can paste the data where I want to. What...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.