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...