public class Test
public Shared Sub Main
Dim objExcel As Excel.Application
objExcel = New Excel.Application
Dim objSheet As New Excel.Worksheet
Dim objData As Excel.Range
Dim intCol, intRow As Integer
objExcel.Visible = True
TextBox1.Clear()
objSheet = objExcel.Workbooks.Open("C:\Temp\Test.xls").Worksheets.Item(1)
objExcel.Range("A2:E3").Select()
objData = objExcel.Selection
For intCol = 1 To 5
For intRow = 1 To 2
Console.WriteLine(objData(intRow, intCol).Value)
Next
Next
objExcel.Workbooks.Close()
objExcel.Quit()
objExcel = Nothing
End Sub
End class
|