Imports System.Globalization
Imports Microsoft.Office.Interop.Excel
Private Sub Excel_export()
Dim objExcelWbk As Microsoft.Office.Interop.Excel.Workbook
Dim objExcelsht As Microsoft.Office.Interop.Excel.Worksheet
Dim objExcelApp As Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application")
objExcelWbk = objExcelApp.Workbooks.Open("c:\tmp\vorlage.xlsx")
objExcelsht = objExcelWbk.Sheets(1)
objExcelsht.Range("A1").Value = "test"
Try
objExcelApp.objExcelWbk.objExcelsht.range("A1").value = "test"
Catch ex As Exception
End Try
End Sub
Imports System.Globalization
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objExcelWbk As Microsoft.Office.Interop.Excel.Workbook
Dim objExcelsht As Microsoft.Office.Interop.Excel.Worksheet
Dim objExcelApp As Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application")
objExcelWbk = objExcelApp.Workbooks.Application.ActiveWorkbook
'objExcelWbk = objExcelApp.Workbooks.Open("c:\tmp\vorlage.xlsx")
objExcelsht = objExcelWbk.Sheets(1)
objExcelsht.Range("A1").Value = "test"
Try
objExcelApp.objExcelWbk.objExcelsht.range("A1").value = "test"
Catch ex As Exception
End Try
End Sub
End Class
Imports System.Globalization
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim objExcelWbk As Microsoft.Office.Interop.Excel.Workbook
Dim objExcelsht As Microsoft.Office.Interop.Excel.Worksheet
Dim objExcelApp As Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application")
Dim rw As Integer = 1
Dim tgtcolm As Integer '= 21
Dim tgtcell As String
Dim LstBaseColm As Integer
Dim LastRow As Long
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
objExcelWbk = objExcelApp.Workbooks.Application.ActiveWorkbook
'objExcelWbk = objExcelApp.Workbooks.Open("c:\tmp\vorlage.xlsx")
objExcelsht = objExcelWbk.Sheets(1)
'---------------------------------- searching tgtcolm ---------------------------------
tgtcell = objExcelsht.Cells(1, 1).Value
While tgtcell <> ""
tgtcolm = tgtcolm + 1
tgtcell = objExcelsht.Cells(1, tgtcolm).Value
End While
LstBaseColm = tgtcolm
'tgtcolm = tgtcolm + 1
'-------------------------------------- find last row ----------------------------------
With objExcelsht
While objExcelsht.Cells(rw, 2).value IsNot Nothing
Dim test As String = objExcelsht.Cells(rw, 2).value.ToString
rw = rw + 1
End While
LastRow = rw - 1
End With
MsgBox(LastRow)
End Sub
End Class