Import data : Excel « Windows « VB.Net Tutorial






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








24.21.Excel
24.21.1.Create function in Excel
24.21.2.Create a Spreadsheet
24.21.3.Import data
24.21.4.Sort imported data
24.21.5.Calculate Expression