עבודה עם אקסל

codeman

New member
עבודה עם אקסל

שלום אני פותח מסמך אקסל דרך VB , משנה אותו שומור ומדפיס, סוגר אך תמיד האקסל נשאר פעיל בטבלת המשימות והמסמך נחסם לשינויים בסוף העבודה אני כותב xlSheet = Nothing xlBook = Nothing xlApp = Nothing וזה לא עוזר למישהו יש רעיון? תודה
 

codeman

New member
לפניי השורות הנ"ל אני מבצע

xlSheet.Application.Quit() האם יש צורך בעוד משהו?
 

EdotK

New member
יצירת וסגירת אובייקט אקסל

#region Excel Init Excel.Application ExcelApp; Excel._Workbook ExcelWorkBook; Excel._Worksheet ExcelWorkSheet; Excel.Range ExcelRange; GC.Collect();// clean up any other excel files ExcelApp = new Excel.Application(); ExcelApp.Visible = false; //Get a new workbook. ExcelWorkBook = (Excel._Workbook)(ExcelApp.Workbooks.Add(System.Reflection.Missing.Value)); ExcelWorkSheet = (Excel._Worksheet)ExcelWorkBook.ActiveSheet; #endregion #region Excel Cleanup // Need all following code to clean up and extingush all references!!! ExcelWorkBook.Close(null, null, null); ExcelApp.Workbooks.Close(); ExcelApp.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelRange); System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApp); System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkSheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkBook); ExcelWorkSheet = null; ExcelWorkBook = null; ExcelApp = null; GC.Collect(); // force final cleanup! #endregion​
 

BogN

New member
עשיתי את זה פעם

ואני זוכר שגם עם הפקודה System.Runtime.InteropServices.Marshal.ReleaseComObject האובייקט עדיין נשאר לי בזכרון... חפרתי בתיעוד של מיקרוסופט והם לא מוכנים לקחת אחראיות על הנושא הזה... כך שאם זה לא עוזר לך אז תצטרך לחשוב על פתרון אחר... אני בדקתי מה הקוד של הפרוסס של האקסל שנוצר כתוצאה מהתוכנית, ואם הוא עדיין היה שמה אז הרגתי אותו... אגב, הייתה לי את הבעיה הזו ב-2003 SERVER...
 
למעלה