Skip to main content

Get-Column-Headers

Command Description

Return all column names of a datatable in an array

Command Prototype

arrayColumns = Datatable.GetColumns(dtTable)

Parameter Description

ParameterRequiredTypeDefaultDescription
dtTableTrueexpressionobjDatatableThe data table to be filtered

return

arrayColumns,The variable used to save the output of the command.

Demo

aryData = [["a", 1], ["b", 2], ["c", 3], ["d", 1]] 
aryColumns = ["letter", "number"]
objDatatable = Datatable.BuildDataTable(aryData,aryColumns)
arrayColumns = Datatable.GetColumns(objDatatable)

TracePrint(arrayColumns)
// ["letter","number"]