Get first cell of a Datatable with headers

datatable
activities

#1

Hi does anyone know how to get the first cell of a datatable? I’m looking for the cell A1 (which is a column name in this case because I have headers) not the first item of the datatable.


#2

@inyourgravity, Assign activity

String strFirstColName = (From col in dt.Columns.CastOf(System.Data.DataColumns)
Select Cstr(col.columnName)).Tolist()(0)

Regards,
Dom :slight_smile:


#3

HI @inyourgravity,
use the below code to get first column name from the data table.
Datatable.Columns(0).ColumnName.ToString()

Regards,
Arivu


#4

If you read it from an excel file you can just use ReadCell activity indicating cell A1 or if you already have the DataTable, the easiest way is:
yourDataTable.Columns(0).ColumnName