C
charmis
Hi everyone,
I am trying to include one feature using excel object in my application.
I am giving the code to create and kill the process , that i got from
Microsoft site.......but nothing is happening
it will create one process but , it wont close . i used the code from the
link below:
http://www.dotnet247.com/247reference/a.aspx?u=http://support.microsoft.com/?kbid=317109
How can i kill the process?
Also will this work in Windows server 2003
// function
private void NAR(object o)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
}
catch {}
finally
{
o = null;
}
}
// button click
private void Button1_Click(object sender, System.EventArgs e)
{
PIA.ApplicationClass excelApplication = new PIA.ApplicationClass();
PIA.Workbook excelWorkbook =
((PIA.Workbook)excelApplication.Workbooks.Add(System.Reflection.Missing.Value));
PIA.Worksheet excelSheet = ((PIA.Worksheet)(excelWorkbook.ActiveSheet));
NAR(excelSheet);
excelWorkbook.Close(false,null,null);
NAR(excelWorkbook);
excelApplication.Quit();
NAR(excelApplication);
Debug.WriteLine("Sleeping...");
System.Threading.Thread.Sleep(1000);
Debug.WriteLine("End Excel");
GC.Collect();
GC.WaitForPendingFinalizers();
}
thanks & regards
charmis
I am trying to include one feature using excel object in my application.
I am giving the code to create and kill the process , that i got from
Microsoft site.......but nothing is happening
it will create one process but , it wont close . i used the code from the
link below:
http://www.dotnet247.com/247reference/a.aspx?u=http://support.microsoft.com/?kbid=317109
How can i kill the process?
Also will this work in Windows server 2003
// function
private void NAR(object o)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
}
catch {}
finally
{
o = null;
}
}
// button click
private void Button1_Click(object sender, System.EventArgs e)
{
PIA.ApplicationClass excelApplication = new PIA.ApplicationClass();
PIA.Workbook excelWorkbook =
((PIA.Workbook)excelApplication.Workbooks.Add(System.Reflection.Missing.Value));
PIA.Worksheet excelSheet = ((PIA.Worksheet)(excelWorkbook.ActiveSheet));
NAR(excelSheet);
excelWorkbook.Close(false,null,null);
NAR(excelWorkbook);
excelApplication.Quit();
NAR(excelApplication);
Debug.WriteLine("Sleeping...");
System.Threading.Thread.Sleep(1000);
Debug.WriteLine("End Excel");
GC.Collect();
GC.WaitForPendingFinalizers();
}
thanks & regards
charmis