473,729 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2006
"kunal" <ku************ ***@patni.com> wrote in message
news:uo******** ******@TK2MSFTN GP14.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.Applicati onClass oXL = new Excel.Applicati onClass();
oXL.WindowState =Excel.XlWindow State.xlMaximiz ed;
oXL.ShowWindows InTaskbar =true;

//oXL.WindowActiv ate +=Microsoft.Off ice.Interop.Exc el.AppEvents_Wi ndowActivateEve ntHandler;
//oXL.Windows =Microsoft.Offi ce.Interop.Exce l.Windows;
oXL.EnableEvent s=true;
oXL.Visible=tru e;

//oXL.ShowStartup Dialog=true;
//oXL.DisplayExce l4Menus = true;
int hwndExcel;
oXL.Visible=tru e;
oXL.WindowState =Excel.XlWindow State.xlMaximiz ed;
oXL.Caption = "Some Caption For Excel Window";
hwndExcel = MyApi.FindWindo w("XLMAIN",oXL. Caption);
string Excelstr1 = hwndExcel.ToStr ing();

System.Diagnost ics.Process [] processArr2=Sys tem.Diagnostics .Process.GetPro cessesByName("E xcel");
int process2cnt,pro cessid=100000;
for(process2cnt =0;process2cnt< processArr2.Len gth;process2cnt ++)
{
if(processArr2[process2cnt].MainWindowHand le.ToString()== Excelstr1)
{
processid=proce ssArr2[process2cnt].Id;
//processArr2[process2cnt].Kill();
break;
}
}
// Form1 oform1 =new Form1();
//pid=oform1.GetP rocessID(oXL);
//ewclass oewclass =new ewclass();
//pid=oewclass.Ge tProcessID(oXL) ;

if(pid!=100000)
//{
Process.GetProc essById(pid).Ki ll();
}
}

*************** *************** *************** *************** **********
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******** ******@TK2MSFTN GP14.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
3371
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 process this .txt file. Goal: I am working on a vba script to:
0
1449
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 currently through System.Diagnostics.Process ,and i am unable to judge the Excel that was created by me only(I have to leave other Excels Untouched).. The another approach WindowHandler is fine with Windows Applications but not working in Web...
5
3035
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 the below API: TargetWorkbook.Save TargetWorkbook.Close
2
6230
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 { mutex=new System.Threading.Mutex( true, mutexName, out createdNew)
16
2702
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 System.Collections.Generic.List<frmMain.sDBTest> LoadTestSet(string TestSetFile, System.Collections.Generic.List<frmMain.sDBTestDBviewList)
9
4548
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 TypeOf obj Is IDisposable Then DirectCast(obj, IDisposable).Dispose()
5
3829
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 code below GC.Collect(0); myBook.Close(null,null,null); myApp.Workbooks.Close();
0
1301
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 Recordset
24
10592
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 isn't working for me is if there are multiple instances of Excel open. I'll explain: Say I have 3 instances of Excel opened, each with one workbook. Instance 1 = Book1, instance 2 = Book2, and instance 3 = Book3. I want to paste my data to Book3,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.