Remove data table header from a data table

Hi Team,

I have to remove header from a data table how to do it.

Note: While reading the data from file we can uncheck the header but that is not the case we are having data table with header and need to remove.

Hi @Mohammad_Imran

Please try the below linq
dt = dt.Rows.RemoveAt(0)

Follow below steps
Get a row which you have to remove using assign activity

rowToDelete = dataTable.AsEnumerable().FirstOrDefault(Function(row) row.Field(Of String)(“A”) = “<column_header_value_ColumnA>“)

Remove row using remove-data-row-column activity

getting error

The internal structure of a Datatable defines Columns, which are mandatory and Columns cannot be removed from this internal structure.

We would sugggest to have a closer look at your scenario and details

  • Detail usage of the datatable
  • Check of the datatable data and the first row
    • if it is populated with header values and also what are the datable column names

Based on additional information (especially on the datable usage) we can have a look at a more adequate solution approach for your use case

Hi,

you can not delete/remove table header in datatable. But you can ignore the header when you read an excel file and store as a datatable. Also you can simply use default column names as Column1, Column2 etc.

If you find this as a solution, mark as solution. Else please share more information about your query

Read the datatable and uncheck the add header property then use
DataTable.Rows.RemoveAt(0)

It’ll consider the header as data row and it’ll delete itb

if this is needful mark it as SOLUTION

Happy Automation

I found the solution first we have to convert datatable into text then use this in assign activity dt_Text.Substring(dt_Text.IndexOf(vbCrLf)).ToString

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.