Show Information in a label

mattcya

Member
Joined
Jun 18, 2004
Messages
16
Programming Experience
Beginner
Hi Guys,

Just want to know how to display a spreadsheet column from excel into a label field.

Here is my code i am new to vb.net so be nice ;)

'Displays Spreadsheet information in label fields

Dim Xl = CreateObject("Excel.Application")

Dim XLB As Object

Dim XlS As Excel.Worksheet

XLB = Xl.Workbooks.Open("c:\Temp\candidate.csv")
XlS = CType(XLB.Worksheets("candidate"), Excel.Worksheet)



Label1.Text = XlS.Columns.Show(1)


Cheers!

Mattcya
 
So i add a refernce to excel and then connect using a odbc. soryy but would you be able to give me an example

Much appreciated :)
 
Remeber this post?: reading from excel sheet

Once you have the data in a dataset (or just a dataTable), you can either add dataBindings or set the value explicitly to a row/Column in the dataset Table.

To add dataBindings, either use the properties pane or use code like this:
Label1.DataBindings.Add("Text",dataSource,dataMember)
Explicitly:
Label1.Text = dataSet.dataTable(index).Rows(index).Item("ColumnName").ToString
 
Back
Top