L
Luigi
Sorry for my bad english.
I have this problem.
I need open and close a file of Excel
because I have to calculate some
functions on a sheet.
This class:
//....................
//....................
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
internal class OpenExcel
{
Microsoft.Office.Interop.Excel.Application objApp;
Microsoft.Office.Interop.Excel._Workbook objBook;
Microsoft.Office.Interop.Excel.Workbooks objBooks;
public void ExOpen(string PathFile)
{
try
{
objApp = new Microsoft.Office.Interop.Excel.Application();
objBooks = objApp.Workbooks;
objBook = objBooks.Open(PathFile,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
objApp.DisplayAlerts = false;
objBook.Save();
objApp.DisplayAlerts = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
objBook.Close(false, PathFile, null);
objApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBook);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBooks);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objApp);
}
}
}
works ok, but I see the process in task manager.
What's the matter?
Thank you.
Luigi.
I have this problem.
I need open and close a file of Excel
because I have to calculate some
functions on a sheet.
This class:
//....................
//....................
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
internal class OpenExcel
{
Microsoft.Office.Interop.Excel.Application objApp;
Microsoft.Office.Interop.Excel._Workbook objBook;
Microsoft.Office.Interop.Excel.Workbooks objBooks;
public void ExOpen(string PathFile)
{
try
{
objApp = new Microsoft.Office.Interop.Excel.Application();
objBooks = objApp.Workbooks;
objBook = objBooks.Open(PathFile,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value);
objApp.DisplayAlerts = false;
objBook.Save();
objApp.DisplayAlerts = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
objBook.Close(false, PathFile, null);
objApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBook);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBooks);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objApp);
}
}
}
works ok, but I see the process in task manager.
What's the matter?
Thank you.
Luigi.