Ich habe ein Formular in VB.NET mit .NET 4.5. Ich habe eine EXCEL-Datei neben dem Formular geöffnet.Live Update-Daten in Excel-Tabelle von VB.NET Formular
Ich möchte die aktualisierten Daten aus Code, LIVE, in der EXCEL-Tabelle sehen. Aber kann die Daten nicht sehen.
Unten ist der Code
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Me.OpenFileDialog1.ShowDialog()
Dim xlApp As Application
Dim xlWorkBook As Workbook
Dim xlWorkSheet As Worksheet
xlApp = New ApplicationClass
'xlApp.ScreenUpdating = False
xlWorkBook = xlApp.Workbooks.Open("E:\BACKUP\TRY.xls")
xlWorkSheet = xlWorkBook.Worksheets("Sheet1")
'display the cells value B2
MsgBox(xlWorkSheet.Cells(8, 1).value) 'GETTING EXISTING VALUE OK
'edit the cell with new value
xlWorkSheet.Cells(2, 2) = "HI" 'WANT TO SEE THIS DATA BEING LIVE UPDATED
'xlWorkBook.Close() 'DONT WANT TO CLOSE THE OPENED SHEET/WORKBOOK
'xlApp.ScreenUpdating = True
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
End Class