.net - Quit excel instance as class member on demand -


after "text" itemprop = "text">

I try to create a square where I want to work with an Excel instance and I demand that drop On the example excellence (want to be outlined in still want to be able to differentiate the following ways in the garbage colletion:.

  Import excel = Microsoft.Office.Interop.Excel Folk Class Form1 Personal sub Form1_Load (as the object, E EventArgs) handles MyBase.Load dim xlsInst New ExcelInst GC.C As ollect () GC.WaitForPendingFinalizers () End Sub ending class folk classroom ExcelInst sub new () Dim myxlApp New Excel.Application dim myxlWb Excel.Workbook as' ~~ & gt; a new workbook as myxlWb = myxlApp .Workbooks.Add '~~ & gt; Display Excel myxlApp.Visible = true myxlApp.Quit () End Sub Ending Class  
Excel

Overview The task manager is loaded as a form I am not satisfied with the class. Ause I make the personal variable of myxlApp and myxlWB Want to But if I change my class to

  public class ExcelInst Personal MyxlApp New Excel.Application as personal myxlWb Excel.Workbook sub New () '~~ & gt; Add a new workbook to myxlWb = myxlApp.Workbooks.Add '~~ & gt; Display Excel myxlApp.Visible = true myxlApp.Quit () End Sub End Class  

Excel no longer closes on demand. Doese anyone know (why does the snippet work according to my needs and not the other?

after "div class =" text "itemprop =" text ">

I will assume that you still have a reference to xlsInst before the GC, compile and that object contains the references of Excel, GC will not collect. XlsInst = Do not try to do anything before collecting, And maybe not set the variable to anything in the class.

< Pre> Private sub form 1_load (object as sender, and sender in event as ARG) MyBase handles. New Exceline xlsInst = Add as some GC compiler () GC VATFORDFiNIEZ () and sub end class Public class ExcelInst Personal MyxlApp as new Excel application as private myxlWb Excel. Workbook sub new () '~~ & gt; Add a new workbook myxlWb = myxlApp.Workbooks.Add' ~~> Excel myxlApp displays Please .Visible = True myxlApp.Quit () Myxl App = None MyxlWb = Nothing End Sub End Class

I have to add, I find it strange that the argument should be within the new (). I suggest keeping it in a steady job or like a processing axle () or .closeExcel () function.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -