N
Namrata
Hi,
I am using Excel for reporting. For opening excel file I have write code :
exlApp = null;
exlApp = new ApplicationClass();
//try
//{
object missing = System.Reflection.Missing.Value;
string path = System.IO.Path.GetFullPath(@"Templates\Log.csv").ToString();
excelWorkbook = exlApp.Workbooks.Open(path, missing,
1,
missing,
Excel.XlTextQualifier.xlTextQualifierNone,
missing,
missing,
missing,
true, //COMMA
missing,
missing,
missing,
missing
);
path = "";
path = System.IO.Path.GetFullPath(@"Reports").ToString();
path = path + @"\" + frmSiteName.siteName + " GenSumm " + DateTime.Now.Day +
"_" + DateTime.Now.Month + "_" + DateTime.Now.Year + " " + DateTime.Now.Hour
+ "." + DateTime.Now.Minute + ".csv";
excelWorkbook.SaveAs(path, missing, missing, missing, missing, missing,
XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing);
object pwd = "cgclogic";
excelWorkbook.Unprotect(pwd);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
excelWorksheet = (Excel.Worksheet)excelSheets.get_Item("Log Report");
excelWorksheet.Unprotect(pwd);
And before that form termination, write code :
excelWorkbook.Save();
exlApp.Workbooks.Close();
exlApp.Quit();
exlApp = null;
excelWorksheet = null;
excelWorkbook = null;
This form is opening through MDI.
But even after form close 'Windows Task Manager' is showing 'Excel' in
process.
And after application colse it is removing from task manager.
When that file in the reports folder try to open, it is giving error : "
This file is already opened . DO you want to reopen the file ?" or " This
file is being modified by other user . Open a read-only copy."
please tell how to close that file using code.
I am using Excel for reporting. For opening excel file I have write code :
exlApp = null;
exlApp = new ApplicationClass();
//try
//{
object missing = System.Reflection.Missing.Value;
string path = System.IO.Path.GetFullPath(@"Templates\Log.csv").ToString();
excelWorkbook = exlApp.Workbooks.Open(path, missing,
1,
missing,
Excel.XlTextQualifier.xlTextQualifierNone,
missing,
missing,
missing,
true, //COMMA
missing,
missing,
missing,
missing
);
path = "";
path = System.IO.Path.GetFullPath(@"Reports").ToString();
path = path + @"\" + frmSiteName.siteName + " GenSumm " + DateTime.Now.Day +
"_" + DateTime.Now.Month + "_" + DateTime.Now.Year + " " + DateTime.Now.Hour
+ "." + DateTime.Now.Minute + ".csv";
excelWorkbook.SaveAs(path, missing, missing, missing, missing, missing,
XlSaveAsAccessMode.xlNoChange, missing, missing, missing, missing);
object pwd = "cgclogic";
excelWorkbook.Unprotect(pwd);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
excelWorksheet = (Excel.Worksheet)excelSheets.get_Item("Log Report");
excelWorksheet.Unprotect(pwd);
And before that form termination, write code :
excelWorkbook.Save();
exlApp.Workbooks.Close();
exlApp.Quit();
exlApp = null;
excelWorksheet = null;
excelWorkbook = null;
This form is opening through MDI.
But even after form close 'Windows Task Manager' is showing 'Excel' in
process.
And after application colse it is removing from task manager.
When that file in the reports folder try to open, it is giving error : "
This file is already opened . DO you want to reopen the file ?" or " This
file is being modified by other user . Open a read-only copy."
please tell how to close that file using code.