killing Excel instance through ASP.NET

Discussion in 'ASP .Net' started by kunal.kewalramani@patni.com, Mar 4, 2005.

  1. Guest

    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...
     
    , Mar 4, 2005
    #1
    1. Advertising

  2. Mark Rae Guest

    "kunal" <> wrote in message
    news:...

    > 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.
     
    Mark Rae, Mar 4, 2005
    #2
    1. Advertising

  3. Guest

    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_WindowActivateEventHandler;
    //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.GetProcessesByName("Excel");
    int process2cnt,processid=100000;
    for(process2cnt=0;process2cnt<processArr2.Length;process2cnt++)
    {
    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...
     
    , Mar 4, 2005
    #3
  4. 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" <> wrote in message
    news:...
    > 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...
     
    Steve C. Orr [MVP, MCSD], Mar 4, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shruti A via .NET 247
    Replies:
    0
    Views:
    743
    Shruti A via .NET 247
    May 15, 2004
  2. Joe Warrington

    Killing an instance?

    Joe Warrington, Jul 18, 2004, in forum: Java
    Replies:
    14
    Views:
    598
    Xavier Tarrago
    Jul 22, 2004
  3. =?Utf-8?B?QmFyZW4=?=

    Killing Excel instance

    =?Utf-8?B?QmFyZW4=?=, May 21, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    368
    George Ter-Saakov
    May 21, 2007
  4. atoi
    Replies:
    1
    Views:
    157
    Ray at
    Oct 16, 2003
  5. KK

    Killing COM+ object instance

    KK, May 20, 2005, in forum: ASP General
    Replies:
    1
    Views:
    148
    StephenMcC
    May 20, 2005
Loading...

Share This Page