0

Help, I want to pass the data from sheet1 (Home) of excel, to my datagridView Content in Form1.

 Sub LoadDataGridView()

    Dim sSheet As Excel.Worksheet = Globals.ThisWorkbook.Sheets("Home")
    Dim MyRegionSelected As Excel.Range = sSheet.Range("A1")
    Dim ultFila As Long = MyRegionSelected.CurrentRegion.Rows.Count
    Dim i As Long

    For i = 2 To ultFila

        dgvlist.Columns(0).HeaderText = "Name"
        dgvlist.Columns(1).HeaderText = "Number"

        dgvlist.DataSource = sSheet.Cells(i, 1).ToString
        dgvlist.DataSource = sSheet.Cells(i, 2).ToString

        Exit For

    Next

End Sub
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • The following may be helpful: https://stackoverflow.com/questions/18511576/reading-excel-file-using-oledb-data-provider or https://learn.microsoft.com/en-us/answers/questions/536933/c-reading-excel-data-using-oledb-does-not-work-wel.html – Tu deschizi eu inchid Mar 20 '22 at 01:29
  • thank you very much but what I want is in VSTO without DATABASE – Alynson Mar 20 '22 at 01:58
  • in VBa visual basic was going to excel, now Excel goes to Visual bacic... VSTO is the plugin in Visual Studio – Alynson Mar 20 '22 at 02:06

0 Answers0